Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

PHP code display in browser instead of executing it

Posted on 2011-09-07
13
Medium Priority
?
506 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 2000 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
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 …
Suggested Courses

886 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