Page 1 of 1
Can't execute php, it downloads instead
Posted: Sat Oct 08, 2005 1:18 pm
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.
Posted: Sat Oct 08, 2005 2:46 pm
by feyd
not to sound condescending, but did you remember to restart Apache after editing the file?
Posted: Sat Oct 08, 2005 2:55 pm
by shadow_005
Yes I did.
Posted: Sat Oct 08, 2005 4:20 pm
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.
Posted: Sun Oct 09, 2005 2:50 am
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

.
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.
Posted: Sun Oct 09, 2005 6:58 am
by sheila
The phpinfo.php file in the htdocs folder does work btw.
Is short_open_tag ON or OFF?
Posted: Sun Oct 09, 2005 11:20 am
by shadow_005
short_open_tag = On
Posted: Sun Oct 09, 2005 6:08 pm
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.