PHP code display in browser instead of executing it

I have just configured the PHP 5.3.8 from PHP.net and apache 2.2.20 from apachelaunge on Windows 7.

Every thing done very well.

I have tried
PHP -i

Open in new window

from the command line and it show me all PHP infomarmation.

But when I have tried to execute the
<?php phpinfo(); ?>

Open in new window

, then browsers shows me the same content as in php file but not the actual PHP execution result.

I have added Directory Index also like below:

<IfModule dir_module>
    DirectoryIndex index.php index.html index.htm
</IfModule>

Open in new window


I am not getting where I am wrong.
LVL 12
Avinash ZalaWeb ExpertAsked:
Who is Participating?
 
haloexpertsexchangeConnect With a Mentor Commented:
I am working with xp but it should be about the same no matter what so you go under system properties then the advanced tab and at the bottom there should be a button for the environment variables.
Then you have to look under system variables, not user variables, and add them there. If you do not find them or if the information is not correct you can edit them. For the path variable just edit the current value and add it to what is already there.
0
 
haloexpertsexchangeCommented:
do you have something like this in your httpd.conf file? This is what mine has to have to run php.
#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
PHPIniDir "C:\Program Files\PHP"
LoadModule php5_module "php5apache2_2.dll"
#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
0
 
Avinash ZalaWeb ExpertAuthor Commented:
Yes I have below code :


#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
PHPIniDir "C:\PHP\"
LoadModule php5_module "C:\PHP\php5apache2_2.dll"
#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL

Open in new window

0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
haloexpertsexchangeCommented:
If you are running a windows server do you have the environment variables set up?
That should be one set up called PHPRC with the path to the php install as it value as well for good measure the path to the php install should be added to the Path environment variable.
0
 
haloexpertsexchangeCommented:
also don't forget to restart apache after making any changes to the httpd.conf file so that the go into effect.
0
 
Avinash ZalaWeb ExpertAuthor Commented:
how to set that?
0
 
Avinash ZalaWeb ExpertAuthor Commented:
i have changed it and updated, and apache restarted but still same. I have to restart machine for setting up the environment variable?
0
 
haloexpertsexchangeCommented:
not that i know of, just apache so that it notices the new information.
Can you successfully serve up a normal html page from apache?
0
 
Avinash ZalaWeb ExpertAuthor Commented:
yes, PHPinfo is now showing. thanks for this.

But it gives error of the mysql extension is not loading. but there is php_mysql.dll exists in my php extension dir.
0
 
haloexpertsexchangeCommented:
is it set up as an extension correctly in your php.ini file?
0
 
Avinash ZalaWeb ExpertAuthor Commented:
yes this line is uncommented : extension=php_mysql.dll

and php_mysql.dll exists in ext directory..
0
 
Avinash ZalaWeb ExpertAuthor Commented:
all done...

i have copied libmysql.dll from mysql's lib directory and placed it into PHP folder.

after this restart apache and mysql.

0
 
Avinash ZalaWeb ExpertAuthor Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.