Results 1 to 9 of 9

Thread: AWS PHP script problems

  1. #1
    Junior Registered
    Join Date
    Apr 2004
    Posts
    4

    AWS PHP script problems

    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.

    PHP Code:
    $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_WHITE,1);
    xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,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?

  2. #2
    Registered GCT13's Avatar
    Join Date
    Aug 2003
    Location
    NYC
    Posts
    480
    Hi tempyyyst,

    This line
    PHP Code:
    echo ('$xmlFeed); 
    will probably get you trouble. Remove it, or replace it with
    PHP Code:
    echo $xmlFeed'<br /><br />'
    Hope that helps,

    Dan
    ....

  3. #3
    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.

  4. #4
    Junior Registered
    Join Date
    Apr 2004
    Posts
    4
    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.

  5. #5
    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.

    PHP Code:
    <?
    $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_WHITE,1);
    xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,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 />';
    }
    }
    ?>

  6. #6
    Registered GCT13's Avatar
    Join Date
    Aug 2003
    Location
    NYC
    Posts
    480
    Still having the problem tempyyyst?
    ....

  7. #7
    Junior Registered
    Join Date
    Apr 2004
    Posts
    4
    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?
    Last edited by tempyyyst; 04-03-2004 at 09:51 AM.

  8. #8
    Registered GCT13's Avatar
    Join Date
    Aug 2003
    Location
    NYC
    Posts
    480
    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
    ....

  9. #9
    Junior Registered
    Join Date
    Apr 2004
    Posts
    4
    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
    Last edited by tempyyyst; 04-04-2004 at 08:02 AM.

Similar Threads

  1. Review: Professional PHP Programming
    By Chris in forum Books
    Replies: 6
    Last Post: 07-17-2013, 05:26 AM
  2. Looking for affiliates.. (to sell a PHP script)
    By listenmirndt in forum The Marketplace
    Replies: 4
    Last Post: 04-12-2004, 02:58 AM
  3. Anybody found a shopping cart script to use with AWS?
    By RockNRollPig in forum Advertising & Affiliate Programs
    Replies: 7
    Last Post: 02-18-2004, 06:44 PM
  4. php script problems
    By wrigh_g in forum HTML, CSS, Layout, and Design
    Replies: 4
    Last Post: 01-24-2004, 06:54 AM
  5. Redirect script with statistics, graphs, etc
    By emke in forum Website Programming & Databases
    Replies: 7
    Last Post: 05-20-2003, 03:44 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •