Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm sure I'm doing something rather silly but I cannot work out what is going on. I have recently downloaded and installed Fedora 14 on my server. I am trying to write some PHP. I cannot however, get some of its functionality to work.
Here's an example: SimpleXmlElement. I read that it is part of the core PHP package and thus no 'import'/'include'/etc. is needed. However, on my server, using Firefox 3.6.12, the webpage just crashes on the line
Code:
$x = new SimpleXmlElement($content);
and I get no output afterwards.
Running it in the command prompt I get, what looks like, the correct output, but with these added warnings, which I don't understand:
Code:
PHP Warning: SimpleXMLElement::__construct(): Entity: line 8: parser error : Entity 'raquo' not defined in includes/functions.php on line 7
PHP Warning: SimpleXMLElement::__construct(): <title>Nettuts+ » We are making some changes!</title> in includes/functions.php on line 7
PHP Warning: SimpleXMLElement::__construct(): ^ in includes/functions.php on line 7
PHP Warning: Invalid argument supplied for foreach() in includes/functions.php on line 11
I know it works as I've tried it on another server successfully. My first thought was that that it maybe some configurations in httpd.conf, but I am not sure.
I'm rather confused! Any help would be greatly appreciated.
I'm sure I'm doing something rather silly but I cannot work out what is going on. I have recently downloaded and installed Fedora 14 on my server. I am trying to write some PHP. I cannot however, get some of its functionality to work.
Here's an example: SimpleXmlElement. I read that it is part of the core PHP package and thus no 'import'/'include'/etc. is needed. However, on my server, using Firefox 3.6.12, the webpage just crashes on the line
Code:
$x = new SimpleXmlElement($content);
and I get no output afterwards.
Running it in the command prompt I get, what looks like, the correct output, but with these added warnings, which I don't understand:
Code:
PHP Warning: SimpleXMLElement::__construct(): Entity: line 8: parser error : Entity 'raquo' not defined in includes/functions.php on line 7
PHP Warning: SimpleXMLElement::__construct(): <title>Nettuts+ » We are making some changes!</title> in includes/functions.php on line 7
PHP Warning: SimpleXMLElement::__construct(): ^ in includes/functions.php on line 7
PHP Warning: Invalid argument supplied for foreach() in includes/functions.php on line 11
I know it works as I've tried it on another server successfully. My first thought was that that it maybe some configurations in httpd.conf, but I am not sure.
I'm rather confused! Any help would be greatly appreciated.
Thanks in advance,
The Godfather
I could be a problem with your php version. What version does it have the server where you tried it?
What version does it have your computer?
Made a simple test.php page with this content:
<?php phpinfo();?>
And compare the output between that server where it works and your computer.
Why not try something simpler, like the suggested phpinfo() call, or even
Code:
<?php
echo "Hello World!";
?>
If you see this, your PHP instance IS working in the first place. If it is, you can start debugging further from there what might be wrong about the other code that you originally posted.
This returns "Hello World!". The PHP installation is working. I have written code, setup forums, wikis etc. but for some reason, I can't get the above code to work. It seems to work on the command line, i.e. when i execute:
Can you post the XML file you are trying to parse? From the error message it looks like it's not proper XML. This is incorrect:
Code:
<xml>
<title>Nettuts+ » We are making some changes!</title>
</xml>
This is correct:
Code:
<xml>
<title>Nettuts+ » We are making some changes!</title>
</xml>
Try to open the XML file in some browser and see if you get any errors.
I also got XML parse errors upgrading PHP to the newer versions. It seems the older versions allowed many weird XML files, whereas the newer versions are more strict.
For example, some XML files coming from some .NET application had the prefix <?xml version="1.0" encoding="unicode"?>. It was actually UTF-16LE and older versions of PHP would parse it, but not the newer ones. After changing the prefix to <?xml version="1.0" encoding="UTF-16"?> they parsed fine.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.