PHP File Downloads Instead of Executes
Posted by: bsb898 (---.lightspeed.dybhfl.sbcglobal.net)
Date: June 05, 2013 05:05AM

I admit up front to being a noob on WAMP, and being spoiled a bit by the fact that most everything today is a simple "install and run" proposition.

So, on to my issue:

I have a working website with a javascript form that executes a simple PHP script to send an e-mail. It works just fine when on my hosted server; but I want to be able to develop more sophisticated scripting, which means I need to be able to test locally. So I downloaded and installed WAMP (Windows 64-bit to pair with my Windows 7 64-bit operating system).

Everything appears to be working. I can access localhost and myPHPadmin. Port 80 is in use by Apache and PHP. The WAMP icon is a cheery green and can be put online and offline.

The trouble is that when I submit the form and it hits the PHP page, the page is downloading rather than executing. I am working in the default www directory and have tried both IE and Chrome.

After spending several hours over the past two days Googling for answers, and finding nothing helpful, my frustration level with it is very high. So, I welcome any suggestions that you may have. smiling smiley

Options: ReplyQuote
Re: PHP File Downloads Instead of Executes
Posted by: RiggsFolly (---.ppp.as43234.net)
Date: June 05, 2013 11:24AM

Have you been playing with the AddType directives in httpd.conf.

It sounds like you are missing this

AddType application/x-httpd-php .php

Or you are using a different extension i.e. your php file is not like this 'filename.php'


Check that the actual filename has a .php extension and not xxx.php.txt

Its always best to change explorers default config to uncheck the 'hide extensions of known file types' so you see exactly what the file name is on disk

Options: ReplyQuote
Re: PHP File Downloads Instead of Executes
Posted by: bsb898 (---.lightspeed.dybhfl.sbcglobal.net)
Date: June 07, 2013 03:32AM

Thanks for your response. I checked the Apache httpd.conf file and had the following PHP-related AddTypes (I haven't modified the file):

AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3


I am also in the habit of changing my windows to show file extensions, but I double-checked that, as well, just to be sure, and my file does truly have a PHP extension.

Any other thoughts? And thanks again for being willing to lend a hand!

Options: ReplyQuote
Re: PHP File Downloads Instead of Executes
Posted by: RiggsFolly (---.ppp.as43234.net)
Date: June 10, 2013 11:54AM

This functionality is all to do with apache knowing that it has to pass php script to the php interpereter.

This is controlled by the AddType and/or AddHandler Apache config commands.

You should have a ' AddType application/x-httpd-php .php' in the <IfModule mime_module> section of your httpd.conf

Also check that you have the Apache Module mime_module activated using the
wampmanager -> Apache -> Apache modules -> mime_module
It should be checked.

Options: ReplyQuote
Re: PHP File Downloads Instead of Executes
Posted by: dianagaby2018 (178.138.97.---)
Date: December 12, 2018 06:28PM

I had this problem and if you actually never played with your server configuration settings, then your problem is 90% in your .htaccess file

You either modify .htaccess file LOCALLY, ore delete it (LOCALLY)

Options: ReplyQuote
Re: PHP File Downloads Instead of Executes
Posted by: Otomatic (Moderator)
Date: December 12, 2018 07:18PM

Hi,

You answer to a message five years after.

------------------------------------------------------------------------------------------------------------
Wampserver 3.1.9 32 bit - Apache 2.4.39 - PHP 7.3.7/7.2.20/7.1.30/7.0.33/5.6.40 - MySQL 5.7.26 - MariaDB 10.3.16
Wampserver 3.1.9 64 bit - Apache 2.4.39 - PHP 7.3.7/7.2.20/7.1.30/7.0.33/5.6.40 - MySQL 5.7.26/8.0.16 - MariaDB 10.3.16
PhPMyadmin 4.9.0.1 - MysqlDumper 1.24.5
on W10 and W7 Pro 64 bit
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons
« Ce n'est pas parce qu'ils sont nombreux à avoir tort, qu'ils ont forcément raison. Coluche »
« It's not because they are many to be wrong, they are necessarily right. Coluche »

Options: ReplyQuote


Sorry, you can't reply to this topic. It has been closed.