954,576 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

PHP not working on Windows XP

I just installed php 5.3 and apache 2.2 on my computer. While Apache seems to know I have php(it shows php 5.3 on the bottom of the apache monitor) when i tried to load a page with phpinfo() nothing shows up. I know i have the right syntax(i have used php b4 but not on my own computer). I feel like something is wrong with my .ini file. I believed I turned the short_tags thing off and in my httpd.conf file i added the lines:
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule php5_module c:/php/php5apache2_2.dll
PHPIniDir "c:/php/"
Can someone please help?

kbjustin
Light Poster
29 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

If short_tags is off then you should use e.g

<?php
phpinfo()
?>

You shouldnt need to manually mofify your httpd.conf, by the way. During the PHP install, tell it you have apache (make sure to choose correct version) and point at the %apachedie%/conf folder and it should "just work"

At least it does for me, but i am using Server 2003.

What versions of PHP and Apache are you using

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
 

5.3 php 2.2 for apache And i actually meant to say i turned short tags on but i tried both ways and nothing. I have a book and i followed its instructions about the httpd.conf file for apache and I entered those right(according to the book)

kbjustin
Light Poster
29 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 
I have a book and i followed its instructions about the httpd.conf file for apache and I entered those right(according to the book)

Reinstall PHP and let the installer do the configuration for you (there is a step called webserver setup, just choose apache 2.2 and point at the directory where httpd.conf resides). See if that works.

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
 

this may sound stupid on my end but the instructions i had never really told me to install/configure they had me download the zip and then extract in c:/php i never really did any installing just modifying the .ini file

kbjustin
Light Poster
29 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

Ah right, download the .msi (windows installer) version, its much less hassle. It just does it all for you....

http://windows.php.net/downloads/releases/php-5.3.0-nts-Win32-VC6-x86.msi

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
 

ok i downloaded the .msi installed it but same problem

kbjustin
Light Poster
29 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

I noticed something strange, i can run php from the cmd so i tried running php test2.php(the file i am trying to get to work) and unless im mistaken I shouldn't see the php syntax when I do only what i will see in the web browser. My code is

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head><title> Work </title></head>
<body>
Please Work
<?
 phpinfo(); 
?>
</body>
</html>


That is also exactly what it prints out when i run php test2.php

kbjustin
Light Poster
29 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

Yep, something is wrong then.

Running phinfo() using the CLI parser, should print to the console the same resulting information you would expect to see on the page (e.g platform, modules loaded etc...), not the code itself.

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
 

now I am extremely confused because when i trying using php cli parser on index.html(the file that was put there when i installed apache) i put phpinfo(with the correct php tags) in it and it works. Then i copied the entire code pasted into another file saved it as a .html file also and tried using the cli parser and it didnt work for that file

kbjustin
Light Poster
29 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

forgot to mention that index.html doesnt display right in a browser only when i use the cli parser

kbjustin
Light Poster
29 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

If php works from the command console but not through the browser then I would say that php is not communicating with the webserver/apache or the php web service has not started up. You might want to check with the command console the command c:\php\php.exe -r 'php_info();' At the top of its output will be hidden errors that may stop the php service from launching. Also, be sure to install apache before php otherwise there might be some configuration problems. And if your using windows, the easiest way the get a web environment setup is by using xampp.

cwarn23
Occupation: Genius
Team Colleague
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
 

Just to make sure, you are something to the effect of "http://localhost/index.htm" in your address bar, NOT something "C:\Documents and Settings\My Documents\index.html", etc... right?

Dukane
Posting Whiz in Training
295 posts since Oct 2006
Reputation Points: 45
Solved Threads: 29
 
If php works from the command console but not through the browser then I would say that php is not communicating with the webserver/apache or the php web service has not started up. You might want to check with the command console the command c:\php\php.exe -r 'php_info();' At the top of its output will be hidden errors that may stop the php service from launching. Also, be sure to install apache before php otherwise there might be some configuration problems. And if your using windows, the easiest way the get a web environment setup is by using xampp.

I ran the command and nothing came up. Also yes i am typing the localhost address in my address bar not the path of the file. And yes i installed apache before i installed php

kbjustin
Light Poster
29 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 
I ran the command and nothing came up. Also yes i am typing the localhost address in my address bar not the path of the file. And yes i installed apache before i installed php


Opps, silly me placing a bug in that one line of php code. There should be no underline in php_info(); and instead be phpinfo();
Also make sure the path on the left side of the command is the path to your php console/exe file. So try the following if you have installed php in C:\php\

c:\php\php.exe -r 'phpinfo();'

And what to do with that code, place it in the windows command terminal located at start->run->type: cmd ->press enter -> type code described above -> press enter. It should list the data in phpinfo() function to check your configurations.

Also I would suggest to do ctrl+alt+delete to see if php is actually running in the background. But would do a reboot first so results aren't misleading. If the php service is not running in the background then it is likely to be a broken dll (eg. corrupted or incompatible).

cwarn23
Occupation: Genius
Team Colleague
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
 

the best way to download the "appserv-win32-2.5.9.exe" zip,it contain php 5 and apache, i used it now.

lad389
Newbie Poster
7 posts since Jul 2009
Reputation Points: 10
Solved Threads: 2
 

When i ran the command it says: PHP Parse Error: parse error in Command line code on line 1. Also while i dont the exact name of hte process for php i dont see anything indicating php is running

kbjustin
Light Poster
29 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 
lad389
Newbie Poster
7 posts since Jul 2009
Reputation Points: 10
Solved Threads: 2
 
you may see this link http://www.daniweb.com/forums/thread70996.html

I cant get the part even to work before he install IIS. Also sort of new to this stuff is there really any difference between IIS and Apache. Also I plan on getting a netbook soon with linux do you think it would just be easier to do all this on the netbook?

kbjustin
Light Poster
29 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

If its an ubuntu based netbook try this

http://www.daniweb.com/forums/thread78131.html

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You