View Full Version : AWS PHP script problems
tempyyyst
04-02-2004, 08:51 AM
Hi all
I've been playing around with the AWS PHP script here on Websitepublisher.net and have come across a really annoying problem.
It's really basic as well.
For some reason, the script doesn't think there's any XML data, even though the url shows the XML in all its glory.
$xmlFeed = 'http://xml.amazon.com/onca/xml3?
t=understandi0a-20&
dev-t=D1AOQCL6YUACVK&
BrowseNodeSearch=16272&
mode=books&sort=+pmrank&
offer=All&type=lite&
page=1&f=xml';
echo ('$xmlFeed);
$data = @implode("",file($xmlFeed));
$parser = xml_parser_create();
xml_parser_set_option($parser,XML_OPTION_SKIP_WHIT E,1);
xml_parser_set_option($parser,XML_OPTION_CASE_FOLD ING,0);
xml_parse_into_struct($parser,$data,$d_ar,$i_ar);
xml_parser_free($parser);
I see the contents of $xmlFeed, but by the time it goes through the @implode function there's no data.
Is there a really obvious reason for this?
GCT13
04-02-2004, 09:18 AM
Hi tempyyyst,
This line
echo ('$xmlFeed);will probably get you trouble. Remove it, or replace it with
echo $xmlFeed. '<br /><br />';Hope that helps,
Dan
freekrai
04-02-2004, 03:46 PM
actually, the only problem with that echo ('$xmlFeed); statement is that he's using single quotes and has no closing quote.
echo ("$xmlFeed"); or echo ($xmlFeed); would work fine.
single quotes don't execute variables.
tempyyyst
04-03-2004, 01:51 AM
Sorry guys, my careless error checking coding has been misleading you all.
That echo statement is only there to report the contents of $xmlFeed back to me, which it's doing fine (despite my quote mistake) - hence why I'm really confused about why the implode function isn't doing anything with the xml.
freekrai
04-03-2004, 07:17 AM
Originally posted by tempyyyst
Sorry guys, my careless error checking coding has been misleading you all.
That echo statement is only there to report the contents of $xmlFeed back to me, which it's doing fine (despite my quote mistake) - hence why I'm really confused about why the implode function isn't doing anything with the xml.
Well, I used the quote you posted above and parsed it after the xml call, and it worked fine displaying the product name and price.
<?
$xmlFeed = 'http://xml.amazon.com/onca/xml3?t=understandi0a-20&dev-t=D1AOQCL6YUACVK&BrowseNodeSea$
echo ($xmlFeed);
$data = @implode("",file($xmlFeed));
$parser = xml_parser_create();
xml_parser_set_option($parser,XML_OPTION_SKIP_WHIT E,1);
xml_parser_set_option($parser,XML_OPTION_CASE_FOLD ING,0);
xml_parse_into_struct($parser,$data,$d_ar,$i_ar);
xml_parser_free($parser);
for($i=0; $i<count($i_ar['Details']); $i++) {
if($d_ar[$i_ar['Details'][$i]]['type']=='open') {
for($j=$i_ar['Details'][$i]; $j<$i_ar['Details'][$i+1]; $j++) {
if($d_ar[$j]['tag'] == 'ProductName'){
$ProductName = $d_ar[$j]['value'];
}elseif($d_ar[$j]['tag'] == 'OurPrice'){
$OurPrice = $d_ar[$j]['value'];
}
}
echo '<strong>' .$ProductName. '</strong> <em>Price: ' .$OurPrice. '</em><br />';
}
}
?>
GCT13
04-03-2004, 09:12 AM
Still having the problem tempyyyst?
tempyyyst
04-03-2004, 09:42 AM
Well, sort of.
It works fine on my local machine, but not on my live server.
I've never had any problems parsing XML before on that machine.
Anything I should be checking? PHP settings etc?
GCT13
04-03-2004, 10:06 AM
On your live machine, I would double and triple check that certain file paths are correct. Most likely there's some root file path that is different from you local machine. Past that, if you think it's a PHP setting, setup the local and live phpinfo() next to each other on your browser and tediously compare line by line for any differences. :(
I would also recommend scrapping your local machine for testing - do all you testing on your live machine. The reason - and I've run into this headache before - is that it is so difficult if not impossible to get you local/live machines synced up exactly. Doing all your testing on the live server will elliminate the "surprises" that inevitably popup up when migrating from your local machine.
Good luck,
Dan
tempyyyst
04-04-2004, 07:12 AM
Thanks for your help Dan.
It seems that my host disabled allow_url_fopen by default. But I've changed php.ini to fix that.
Should be plain sailing now.
Jay
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.