I have this piece of code below which works fine on my remote hosted server, but isnt for some reason working on my local linux machine. Ive tried using file_get_contents as well to get the restful service but it also returns false.
Does anyone know Why this is happening?
thanks :)
$xml_data = simplexml_load_file("****");
if ($xml == FALSE)
{
echo "Failed loading XML\n";
foreach (libxml_get_errors() as $error)
{
echo "\t", $error->message;
}
}
I had the same problem it's just a stupid undeclared point in the simplexml
the xml file format should have a container tag, so, you just have to put a parent tag containing all your data like this:
You are getting this error because remote file access has been disabled on your server. An alternative to this is using CURL.
Use my code below to use CURL:
Now use
$cont
as an object to access different nodes in the xml.Well I had same issue and though I would post this to assist anyone who may have not tried this solution yet.
I had a PHP script which worked fine locally, but when using it on a client server running plesk it would not work and failed when trying to grab the external xml file.
I was trying to reference an external xml file from a php script. The server I was using was running plesk. Before considering changing host, All I simply did was update the settings for PHP on the server to run as an Apache Module instead of FastCGI.
error message which I was receiving (example):
Warning: simplexml_load_file(url) [function.simplexml-load-file]: failed to open stream: Permission denied
This resolved the issue in my case.
I used following reports settings in the PHP script:
use like this
Change:
if ($xml == FALSE)
toif ($xml === FALSE)
(source).Make sure you have
allow_url_fopen
turned on in yourphp.ini
http://php.net/manual/filesystem.configuration.php