I want to read a XML file from a certain link with the following code
$filename = 'http://XXXXX/rss.xml';
$xml = simplexml_load_file($filename);
When I try, I get the following error messages:
wrapper is disabled in the server configuration by allow_url_fopen=0
failed to open stream: no suitable wrapper could be found in
I/O warning : failed to load external entity
Whats the problem? Can it be that the server doesn´t support simplexml_load_file?
When allow_url_fopen is set to 0, you have no permissions to acces URL objects like files. Read official manual for more information.
You can not change this value via .htaccess, so you have to set allow_url_fopen=1 in your php.ini file. If you're using a shared hosting or some kind of it, you should contact hosting technical support and describe them your problem.
Related
Basically i am trying to read the FTP files from serve via cron job.
I am getting following error
Warning: Unknown: Failed to write session data (memcache). Please
verify that the current setting of session.save_path is correct
(tcp://...:11211?persistent=1&weight=1&timeout=1&retry_interval=15)
in Unknown on line 0
I don't have idea why i am getting this error. Any idea what is missing there
Thanks
I'd recommend updating your php.ini to use file based caching unless memcache is what you need.
Change session.save_handler to files.
http://php.net/manual/en/session.configuration.php
Memcache is typically used when you have multiple servers that need to share the same session (a.k.a behind a load balancer)
I called v-webmail using open source to try to fix a few
However, at the time of installation,
Unfortunately this application needs the imap extension
loaded and the version of php to be at least 4.1.0 to run.
Other configuration parameters may also be faulty.
Config file local.config.xml: Writeable!
IMAP Extension loaded: Loaded Message is output.
This file is normally created local.config.xml, and gave the necessary permission to 644.
I wonder what caused this error to why.
Why this error occurred ever know about them?
I am using following code to get current time (hours) in Los Angeles
$response_xml_data = file_get_contents('http://www.earthtools.org/timezone-1.1/34.05223/-118.24368');
$data = simplexml_load_string($response_xml_data);
$dt = new DateTime($data->localtime);
$time = $dt->format('H:i:s');
list($hour, $min, $sec) = explode(':', $time);
echo $hour;
This code is working fine offline, but i am getting following warning message when i put this file online:
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in [PHP file name and line number]
Warning: file_get_contents(http://www.earthtools.org/timezone-1.1/34.05223/-118.24368)
[function.file-get-contents]: failed to open stream: no suitable wrapper could be
found in [PHP file name and line number]
It looks like i am using a wrong method to read XML data, please suggest?
This means that on the server you call "online" the HTTP wrapper is disabled for file functions in PHP.
I believe this is caused by having php's allow_url_fopen setting disabled on your server. This prevents the https wrapper from being available, or something like that.
You can enable allow_url_fopen in your php.ini file and this should error should go away. Not sure of other repercussions of this so know what you are changing before you change it.
Ref: http://php.net/manual/en/filesystem.configuration.php
Basically, you just need to override php default configuration open php.ini
allow_url_fopen = ON
I have to website with a very similar php configuration (actually on the same hosting account), with almost identical php code and with identical file structure. At some point, I call fopen(http://example.com/rssfedd.xml) to retrieve a RSS feed.
on http://sfdmorin.com/accueil/index.php everything works fine, on http://danielpoiriergda.ca/accueil/index.php i get:
Warning: fopen(http://affaires.lapresse.ca/rss/2399.xml)
[function.fopen]: failed to open stream: Permission denied in
/var/www/vhosts/danielpoiriergda.ca/httpdocs/snippet/lastRSS.php on
line 143
$f = fopen("http://affaires.lapresse.ca/rss/2399.xml", 'r');
Both website have php debug mode enabled and both have the same permissions for file and folders.
Both info.php have *allow_url_fopen* enabled for local and master value
Here are the major differences I found on both phpinfo() file:
not working site: Server API CGI/FastCGI
working site: Server API Apache 2.0 Handler
and on the working site there are no php.ini file in the path given by the loaded configuration file field
EDIT:
I know this thread is probably dead, but not the problem.
I check, with Netbeans fill diff, all the PHP code and php.ini are exactly the same on both domain.
I know similar questions were ask, but they did not help me.
Thank you!
Finally, I contacted my webserver tech support and they solve the problem. They did by:
adding an exception to SELinux
I dont have a clue wwhat SELinux is or what they did specificaly.
When my script parses an RSS feed from my local Apache server, it parses fine but when I upload script to the remote hosting server it gives the error:
Warning: Magpie RSS: Failed to fetch (url) and cache is off in magpierss-0.6/rss_fetch.inc
on line 231.
I have searched for possible answers and any suggestions are around enabling and changing cache lifetime. I think that is not the problem - it looks like the problem is with remote hosting Apache server or denied access to my host.
Can anyone help?
check that magpie can open the rss url. Usually with curl being enabled or allow_url_fopen on your server. Also make sure that magpie is able/allowed/permitted to create caching files (if any)
This could be caused by a bad url, the server is busy or not having remote file access allowed in your host.
$errormsg = "Failed to fetch $url "; in source indicative of problem getting to host.
Try checking access from the remote host - if you have ssh & curl enabled just do
curl (url)