Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Sep 2010
    Posts
    46
    Thanks
    1
    Thanked 1 Time in 1 Post

    Common reasons when executing a php program it prints the contents of the php file

    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."

  • #2
    New Coder
    Join Date
    Sep 2010
    Posts
    46
    Thanks
    1
    Thanked 1 Time in 1 Post
    Other php programs I got to print out without printing the whole program verbatum.
    Last edited by Philosophaie; 02-24-2012 at 03:03 PM.

  • #3
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,343
    Thanks
    60
    Thanked 527 Times in 514 Posts
    Blog Entries
    4
    Quote Originally Posted by Philosophaie View Post
    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.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #4
    New Coder
    Join Date
    Sep 2010
    Posts
    46
    Thanks
    1
    Thanked 1 Time in 1 Post
    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 "{".

  • #5
    New Coder
    Join Date
    Sep 2011
    Posts
    80
    Thanks
    0
    Thanked 13 Times in 12 Posts
    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.

  • #6
    New Coder
    Join Date
    Sep 2010
    Posts
    46
    Thanks
    1
    Thanked 1 Time in 1 Post
    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

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Causes:
    1. PHP is not available
    2. Runtime PHP is not enabled (as mentioned, via the use of <? or <% when these tags are not configured in PHP.ini)
    3. 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)
    4. You are accessing via file:// and not via http:// through webserver
    5. 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.

  • Users who have thanked Fou-Lu for this post:

    Philosophaie (02-24-2012)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •