PHP script not running

apps

#1

In my site I have a hyperlink to a php script. When I click on the link instead of running the php script I get a dialog with the options of opening or saving the file. I bet I am overlooking something obvious. Can somebody stir me in the right direction?

Thanks!


#2

The output from a script doesn’t have to be a document, it could be an image file or some other binary. Usually for binary files one would want the browser to prompt to save it or open it with an application instead of showing binary data. So you would need to check with whomever wrote the script to find out if they have written it to suggest the browser prompt.

An .htaccess file can force this suggestion as well. But also a browser can ‘sniff’ the content as well and decide to prompt.

Submit the URL to this service http://web-sniffer.net/

Check the HTTP Response section. If you see a “Content-disposition: attachment” or “Content-Type: application/octet-stream” then your site is telling the browser to either prompt for download or that it is an unknown binary data type.

Customer since 2000 :cool: openvein.org


#3

Thanks so much for your response. Now, this same script runs as expected in another site I have. I tried the sniffer per your suggestion. There was no “Content-disposition: attachment” but there was “Content-Type: application/x-httpd-php” which seems correct to me.

At this point I am at a loss. Thoughts?


#4

[quote]Thanks so much for your response. Now, this same script runs as expected in another site I have. I tried the sniffer per your suggestion. There was no “Content-disposition: attachment” but there was “Content-Type: application/x-httpd-php” which seems correct to me.

At this point I am at a loss. Thoughts?[/quote]
You probably have an AddHandler directive in your .htaccess file (application/x-httpd-php is meaningless to a web browser, so if you see it in an HTTP response, you’ve got problems). If you script will run under PHP 5.2.6 CGI (NOT mod_php or PHP 4.x), go ahead and remove the AddHandler directive.

Customer since 2000 :cool: openvein.org


#5

Again, thank you so much for your help.

Unfortunatelly the .htaccess file does not contain the AddHandler directive. Yet, the behavior is the same. This happens with php files and not with html files. Other thoughts?

Thanks!


#6

Remove/rename all .htaccess files, including those that might be in parent directories. Make a simple PHP script:

<?php phpinfo(); ?>

When you browse to it, the page should say it is running as PHP 5.2.6 CGI/FastCGI. Since you have no .htaccess files now and that is a simple script, thats all that should happen. If something else happens (including if it says 4.4.7 or 4.4.9), contact support and inform them you think Apache isn’t configured to run PHP 5 correctly. If you try to run your problem script and it still doesn’t work then you need to get someone to fix the script (it should output a proper content-type).

Also go to Domains -> Manage Domains and “Edit” the domain so the server config gets refreshed.

Customer since 2000 :cool: openvein.org


#7

Again, THANK YOU for all your help! Sorry for the delay in replying.

Good news: I renamed all the .htaccess files and ran the simple script you suggested and it worked just fine. It displayed PHP 5.2.9 CGI/FastCGI. I restored the .htaccess from the root only and got rid of the others. Then I ran my script and it worked fine.

I got sidetracked because when I ran it again the problem resurfaced. All is well now, it was a matter of clearing the browser’s cache.

Thank you so much for your most excellent solution!!