Jump to content

simplexml_load_file() error


orrymr

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.