Solved

PHP code display in browser instead of executing it

Posted on 2011-09-07
13
392 Views
Last Modified: 2012-05-12
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.
0
Comment
Question by:Avinash Zala
  • 7
  • 6
13 Comments
 
LVL 13

Expert Comment

by:haloexpertsexchange
ID: 36497284
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
 
LVL 12

Author Comment

by:Avinash Zala
ID: 36497321
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
 
LVL 13

Expert Comment

by:haloexpertsexchange
ID: 36497363
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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 13

Expert Comment

by:haloexpertsexchange
ID: 36497375
also don't forget to restart apache after making any changes to the httpd.conf file so that the go into effect.
0
 
LVL 12

Author Comment

by:Avinash Zala
ID: 36497382
how to set that?
0
 
LVL 13

Accepted Solution

by:
haloexpertsexchange earned 500 total points
ID: 36497411
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
 
LVL 12

Author Comment

by:Avinash Zala
ID: 36497440
i have changed it and updated, and apache restarted but still same. I have to restart machine for setting up the environment variable?
0
 
LVL 13

Expert Comment

by:haloexpertsexchange
ID: 36497467
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
 
LVL 12

Author Comment

by:Avinash Zala
ID: 36497488
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
 
LVL 13

Expert Comment

by:haloexpertsexchange
ID: 36497524
is it set up as an extension correctly in your php.ini file?
0
 
LVL 12

Author Comment

by:Avinash Zala
ID: 36497544
yes this line is uncommented : extension=php_mysql.dll

and php_mysql.dll exists in ext directory..
0
 
LVL 12

Author Comment

by:Avinash Zala
ID: 36497622
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
 
LVL 12

Author Closing Comment

by:Avinash Zala
ID: 36498236
thanks
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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 …

860 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