?
Solved

SimpleXMLElement doesn't work under PHP Version 5.2.12

Posted on 2009-12-30
6
Medium Priority
?
329 Views
Last Modified: 2012-05-08
i'm trying to use SimpleXMLElement in a script but the result is always empty.

i found this documenting a version problem "SimpleXML doesnt Work with PHP 5.x: Problem & Solution" <http://blog.taragana.com/index.php/archive/simplexml-doesnt-work-with-php-5x-problem-solution/> but my issue is accessing the php.ini which my isp seem to be discouraging me from modifying it.

i also ran a test and got this "URL file-access is disabled in the server configuration" message confirming my problem.

does anyone know another way of getting around the compatibility issue using "SimpleXMLElement" and "file_get_contents"?

thanks!
0
Comment
Question by:ironpen45
  • 3
5 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 26144814
Please run this and post the output for us here.  It almost sounds like you are running in "safe mode" and that makes no sense at all.  Who is your hosting company?

FWIW, I have some sites at 5.2.12 and have no problems with SimpleXML.
<?php phpinfo(); ?>

Open in new window

0
 
LVL 48

Accepted Solution

by:
hernst42 earned 1000 total points
ID: 26144857
If you get the message "URL file-access is disabled in the server configuration" you won't be able to retrieve external data. Ask your hoster to set allow_url_fopen to On.
0
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1000 total points
ID: 26144882
Man page here:
http://us2.php.net/manual/en/filesystem.configuration.php

My guess is that the script you have is not getting any data because it is prohibited from reading files when the path is a URL.  In that case SimpleXML may not have anything to work with, hence the apparent error.

In addition to checking the PHP information, try adding error_reporting(E_ALL) to the top of your script so you can see all the notices and warnings.  Let us know what you find.

You're not using GoDaddy are you?
0
 

Author Comment

by:ironpen45
ID: 26165927
thanks everyone. my ISP just told me to create a PHP.INI on the directory where i'm running the php scripts with appropriate switches (eg., allow_url_fopen=ON) and that got solved the problem.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 26165949
I am posting an objection to closing this without award of points.  Here is why:

Your original question stated "SimpleXMLElement doesn't work under PHP Version 5.2.12" and we demonstrated that that is not the issue. We asked you to post the phpinfo() but you did not do that.

I wrote "My guess is that the script you have is not getting any data because it is prohibited from reading files when the path is a URL."

hernst42 wrote "Ask your hoster to set allow_url_fopen to On."

So it seems that we told you EXACTLY what was wrong and what to do.

Please reconsider awarding points for this question, thanks.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month16 days, 1 hour left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question