...

View Full Version : Common reasons when executing a php program it prints the contents of the php file



Philosophaie
02-24-2012, 03:35 PM
I have a php program. It runs from a form in an htm file. All it does is print out the file. No parse errors, no blank screen.

The "<?php" has no spaces before or after. The class statement begins with no spaces from the carriage return from the "<?php".

I have had success with class and php objects in the past.

I just need to know some of the "common reasons" why an execution of a php program from a form of a htm file could result in just a "printing of the contents of the php file."

Philosophaie
02-24-2012, 03:42 PM
Other php programs I got to print out without printing the whole program verbatum.

tangoforce
02-24-2012, 03:46 PM
It runs from a form in an htm file.

Daft question but have you saved the php file as .php or are you trying to run a .htm file as php?

If trying to run a .htm file then you'll need to add this to your .htaccess file if using apache:

AddType application/x-httpd-php .htm

The only other reasons php wouldn't run on a .php file is an incorrect configuration.

Philosophaie
02-24-2012, 04:55 PM
I think it is incorrect configuration as you said. The php file is saved as a .php file and the htm file is saved as .htm

I took out all the spaces behind every line. Just the code left. There is only tabs in front of them. There are ";" after all lines except for lines that end in "{".

MarkR
02-24-2012, 05:02 PM
Is there php code in the .htm file? As stated this will not be interpreted as PHP without rules added to the htaccess file.

Another reason could be using short tags '<?' without having short tags enabled in the php.ini.

Philosophaie
02-24-2012, 05:11 PM
No php code in the.htm file. I am running Apache but have no htaccess files associated with this.

I do not have the short tags enabled in php.ini

Fou-Lu
02-24-2012, 07:57 PM
Causes:

PHP is not available
Runtime PHP is not enabled (as mentioned, via the use of <? or <% when these tags are not configured in PHP.ini)
File accessed is not configured to parse as PHP code (there is no filetype set by default to parse as PHP code in httpd.conf)
You are accessing via file:// and not via http:// through webserver
Parsing issues may occur in multibyte saved text files. If so, <?php is not seen as an opening tag or any tag for that matter


Hmm, this seems incomplete, but off the top of my head #3, and #4 are the most common I find.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum