Solved

PHP code display in browser instead of executing it

Posted on 2011-09-07
13
362 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 13

Expert Comment

by:haloexpertsexchange
Comment Utility
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
Comment Utility
how to set that?
0
 
LVL 13

Accepted Solution

by:
haloexpertsexchange earned 500 total points
Comment Utility
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 12

Author Comment

by:Avinash Zala
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
is it set up as an extension correctly in your php.ini file?
0
 
LVL 12

Author Comment

by:Avinash Zala
Comment Utility
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
Comment Utility
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
Comment Utility
thanks
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now