orrymr Posted August 9, 2011 Share Posted August 9, 2011 Hi guys, so I'm trying implement a website which uses data stored in an xml file. It works fine on my computer, but as soon as I try to upload it, I get the following error: Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "..\lib\menu.xml" in /home/ogwareco/public_html/menu.php on line 2 And none of the data gets displayed on the screen. I've Googled this problem, but it's led nowhere. I've got no idea what to do here. I've even tried to set my permissions to 777 (bad idea, I know), to see if it was a permissions thing, but it's not. Any help would be much appreciated, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/244333-simplexml_load_file-error/ Share on other sites More sharing options...
WebStyles Posted August 9, 2011 Share Posted August 9, 2011 Would you like us to guess, or can we see the actual code? this error seems quite straight forward: "(...)in /home/ogwareco/public_html/menu.php on line 2" Guess 1: Whatever is on line 2 of menu.php (probably an include or require ) is pointing to a file that you did not upload, or is in the wrong place. Quote Link to comment https://forums.phpfreaks.com/topic/244333-simplexml_load_file-error/#findComment-1255050 Share on other sites More sharing options...
orrymr Posted August 10, 2011 Author Share Posted August 10, 2011 The file exists I even tried if (file_exists('../lib/menu.xml')){echo "it exists"; } to verify this. <?php $dom = simplexml_load_file("..\lib\menu.xml"); include("../lib/fns.php");?> <html> <head> <h1>Shwarma Co. Menu </h1> <title> Menu Page </title> </head> <body> <form action = "order.php" method="post"> <? menuForm($dom); if (file_exists('../lib/menu.xml')){ echo "it exists"; } ?> <input type = "submit" name = "sbmt" value = "Submit"> </form> </body> </html> Like I said, this works fine on my machine at home. It's when it's uploaded that I get this error. Quote Link to comment https://forums.phpfreaks.com/topic/244333-simplexml_load_file-error/#findComment-1255193 Share on other sites More sharing options...
WebStyles Posted August 10, 2011 Share Posted August 10, 2011 if this works: file_exists('../lib/menu.xml') and this doesn't: simplexml_load_file("..\lib\menu.xml") I would try changing the backslashes to forward slashes. (I'm guessing your machine at home is Windows based, and the server is Linux) Quote Link to comment https://forums.phpfreaks.com/topic/244333-simplexml_load_file-error/#findComment-1255213 Share on other sites More sharing options...
orrymr Posted August 10, 2011 Author Share Posted August 10, 2011 That's exactly it. Thanks for the help! What I did was change the forward slashes to backslashes, and change the double quotes to single quotes (it appears that the backslashes were escaping things). I think I should work on my linux box from now on - just makes sense, the server is linux based, so problems like these will be less confusing. Thanks again, that was very helpful! Quote Link to comment https://forums.phpfreaks.com/topic/244333-simplexml_load_file-error/#findComment-1255287 Share on other sites More sharing options...
WebStyles Posted August 10, 2011 Share Posted August 10, 2011 What I did was change the forward slashes to backslashes you mean you changed the backslashes to forward slashes Quote Link to comment https://forums.phpfreaks.com/topic/244333-simplexml_load_file-error/#findComment-1255291 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.