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
https://forums.phpfreaks.com/topic/244333-simplexml_load_file-error/
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.

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.

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.