Can't execute php, it downloads instead

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
shadow_005
Forum Newbie
Posts: 8
Joined: Sat Oct 08, 2005 1:12 pm

Can't execute php, it downloads instead

Post by shadow_005 »

I just installed Apache, mysql, MyODBC, myphpadmin, JSP and php.

If I try to run a php script trough a website then it wants to download the *.php file instead of executing it.

I added these 3 lines to beginning the "httpd.conf" file.

Code: Select all

LoadModule php5_module "c:/php/php5apache2.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/php"
What did I do wrong? The phpinfo.php file in the htdocs folder does work btw.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

not to sound condescending, but did you remember to restart Apache after editing the file?
shadow_005
Forum Newbie
Posts: 8
Joined: Sat Oct 08, 2005 1:12 pm

Post by shadow_005 »

Yes I did.
jollyjumper
Forum Contributor
Posts: 107
Joined: Sat Jan 25, 2003 11:03 am

Post by jollyjumper »

this probably is a long shot, but I've experienced it a few weeks ago.

My script contained a line: ob_start("ob_gzhandler"); which for some reason corrupted the output of my php file, which caused Internet explorer to download the file, and Firefox showed only rubbish.

So perhaps this could be your problem as well(very small chance though, but you'll never know).

Good luck.

Greetz Jolly.
shadow_005
Forum Newbie
Posts: 8
Joined: Sat Oct 08, 2005 1:12 pm

Post by shadow_005 »

Nope that's not it.

my php code in the file "SendMail.php"

Code: Select all

<?
  $email = $_REQUEST['email'] ;
  $message = $_REQUEST['message'] ;

  mail( "<my mail adress was here>", "Feedback Form Results",
    $message, "From: $email" );
  header( "Location: http://www.example.com/thankyou.html" );
?>
I think i put the php files in the wrong directory. First I had it located in soem random directory together with the *.html file. It didn't work :P.
Then I put it in the "C:\Program Files\Apache Group\Apache2\cgi-bin" directory and changed the php call from
"action="SendMail.php" to "action="C:\Program Files\Apache Group\Apache2\cgi-bin\SendMail.php". Still didn't work. The browser just keeps asking to download the php file instead...

Btw, I tried other php codes/files. But they all gave the same problem, so it's not the code.
sheila
Forum Commoner
Posts: 98
Joined: Mon Sep 05, 2005 9:52 pm
Location: Texas

Post by sheila »

The phpinfo.php file in the htdocs folder does work btw.
Is short_open_tag ON or OFF?
shadow_005
Forum Newbie
Posts: 8
Joined: Sat Oct 08, 2005 1:12 pm

Post by shadow_005 »

short_open_tag = On
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

Then I put it in the "C:\Program Files\Apache Group\Apache2\cgi-bin" directory...
cgi-bin is the most ridiculus directory there is. Absolutely no use for it. Unless you code it to (e.g. .htaccess files), php/perl/etc has no care in the world for what directory you're in.
Post Reply