Guest mshort Posted January 14, 2009 Report Share Posted January 14, 2009 Hey all, I have been trying to do the Shopping cart tutorial and have gotten to a point where its not working how it says it should in the video. below i've posted the code that i've used so if someone can tell me what i'm doing wrong that would be great. thanks in advance index.php <?php require_once '../functions/functions.php' $xml = new SimpleXMLElement(file_get_contents(STORE_XML_FILE)); foreach($xml as $product) { echo "$product->title"; } ?> catalog.xml <?xml version="1.0" encoding="UTF-8"?> TOMATOSOUP Tomato Soup Freshly-made Tomato Soup in a can http://www.ayushveda.com/dietfitness/wp-content/uploads/2008/07/tomatosoup.jpg 1.33 PASTA Linguini real authentic lunguini http://www.cookworm.com/images/linguini-chickpeas-lemon02.jpg 2.55 functions.php <?php /** DEFINE GLOBALS **/ define('STORE_XML_FILE' , '../catalog.xml'); ?> Its just displaying a blank screen instead of the items Quote Link to comment Share on other sites More sharing options...
falkencreative Posted January 14, 2009 Report Share Posted January 14, 2009 I haven't done the videos myself, so I can't really comment too much... However, my guess is that the "catalog.xml" file could be in the wrong location, so PHP can't find it. Double check that the file is in the correct location... according to your code, it should be one folder up from the index.php file. If you have the index.php file and the catalog.xml file in the same folder, I believe you would need to remove the "../" from the STORE_XML_FILE constant. However, before you check that, double check that your "catalog.xml" file has a closing at the end of the file. Your example above didn't include that, so I'm not sure if it is missing or you just forgot to copy that bit. Might be causing an issue. Quote Link to comment Share on other sites More sharing options...
sjhwebdesign Posted January 15, 2009 Report Share Posted January 15, 2009 also in the index file you have: require_once '../functions/functions.php' this suggests that your main site index.php is in a sub directory with catalogue.xml is in the root and functions.php is in the functions/ sub directory. i would suggest that you have index.php in the root, leave functions where it is. then in index.php change: require_once '../functions/functions.php' to: require_once 'functions/functions.php' make sure that catalogue.xml is in the root as this where functions.php is looking for it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.