Solved

PHP code display in browser instead of executing it

Posted on 2011-09-07
13
431 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
This article discusses how to implement server side field validation and display customized error messages to the client.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

617 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