LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-18-2010, 09:14 AM   #1
The Godfather
Member
 
Registered: Jul 2005
Location: England
Distribution: 2.6.15-1.2054_FC5
Posts: 35

Rep: Reputation: 15
PHP Functionality


Hello,

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+ &raquo; 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 have used the code provided here:

http://net.tutsplus.com/demos/08_RSS...eeds/index.php

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
 
Old 11-18-2010, 09:31 AM   #2
fcintron
Member
 
Registered: Oct 2010
Location: México
Distribution: Centos
Posts: 72

Rep: Reputation: 4
Quote:
Originally Posted by The Godfather View Post
Hello,

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+ &raquo; 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 have used the code provided here:

http://net.tutsplus.com/demos/08_RSS...eeds/index.php

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.


Regards
 
Old 11-18-2010, 09:50 AM   #3
The Godfather
Member
 
Registered: Jul 2005
Location: England
Distribution: 2.6.15-1.2054_FC5
Posts: 35

Original Poster
Rep: Reputation: 15
Hi fcintron,

Quote:
Originally Posted by fcintron View Post
What version does it have the server where you tried it?
PHP Version 5.2.6-1+lenny8

Quote:
Originally Posted by fcintron View Post
What version does it have your computer?
5.3.3
 
Old 11-23-2010, 06:11 AM   #4
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,552

Rep: Reputation: 103Reputation: 103
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.
 
Old 11-24-2010, 10:01 AM   #5
The Godfather
Member
 
Registered: Jul 2005
Location: England
Distribution: 2.6.15-1.2054_FC5
Posts: 35

Original Poster
Rep: Reputation: 15
Hi Ryan,

Thanks for your help.

Quote:
Originally Posted by rylan76 View Post
Why not try something simpler, like

Code:
<?php

echo "Hello World!";

?>
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:

Code:
php index.php
I'm so confused.
 
Old 11-25-2010, 04:35 AM   #6
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 448Reputation: 448Reputation: 448Reputation: 448Reputation: 448
Hi

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+ &raquo; 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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Functionality of mod_delete chnlinux Linux - Newbie 0 12-18-2007 11:51 AM
Less functionality in 10.1? powadha SUSE / openSUSE 8 05-27-2006 03:59 PM
Sed functionality collern2 Programming 3 03-31-2006 12:49 AM
nessus and more functionality juanb Linux - Security 1 03-07-2006 06:23 AM
iptables functionality Mux Linux - Networking 2 05-21-2002 07:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 02:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration