• GoDaddy Community
  • VPS & Dedicated Servers
  • VPS & Dedicated Servers

    cancel
    Showing results for 
    Show  only  | Search instead for 
    Did you mean: 
    Go to solution
    Highlighted

    PHP Code Not Showing on My Site

    Just updated my site with PHP Include calls for global areas (Header & Footer) It's working in my localhost environment but not showing on the live site. Not sure what else needs to be done for the PHP to be recognized.


    Economy Linux Hosting with cPanel
    PHP 7.3 set to current
    www.ddwgjax.com

     

    PHP Live Site.jpg

     

    PHP Localhost.jpg
    PHP Issue.jpg

     

    7 REPLIES 7
    Super User III
    Super User III

    Re: PHP Code Not Showing on My Site

    @drc0369 

     

    Thank you for including the screen captures

    When I do a view source on the live site I see

    <!--?php include("includes/header.php"); ?-->

    Where as this should be replacing the the code with with the header.php

    It looks like this is what is in your file

    <?php include("includes/header.php"); ?>

    Which looks correct...

    1) Is it getting replaced when you upload it? What do you see on the server if you edit the page directly in File Manager

    2) I noticed you have your page as .html vs .php while this "shouldn't" affect it, it could

     

     



    I am a GoDaddy End User - Just Like You
    Check out my site! | I currently manage over 300 WordPress Websites
    * Please note that I offer free advice on this forum. If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

    Once your issue is resolved,
    please be sure to come back and click accept for the solution

    Get Better Support on the Community Boards!
    Etiquette When Asking for Help from the Community

    Super User III Super User III
    Super User III

    Re: PHP Code Not Showing on My Site

    I believe it is from the file extension.  By default the server only parses PHP in files that have a php extension.  You could either rename the file and links to be .php or configure the server to run .html files as PHP.

    Re: PHP Code Not Showing on My Site

    Checked File Manager and it still shows as is and not commented out.
    You can make PHP calls from .html files, it's something on the server side that's causing it. May have to check all the PHP settings. Really don't want to change all the files ext to php but may have to if I can't find the issue...

    Re: PHP Code Not Showing on My Site

    You can have PHP calls in a .html file. I'm able to do this locally but have to find the issue on the live server side. Prefer to keep html files and only use php when needed for global areas.

    Super User III
    Super User III

    Re: PHP Code Not Showing on My Site

    @drc0369 

     

    1. Login to your cPanel.
    2. Click the File Manager icon.
    3. Navigate to the document root for the site you wish to change (public_html is the document root for your primary domain).
    4. Select the file titled .htaccess and click Code Editor at the top (If the .htaccess file does not exist you will need to create one).
    5. Add the following lines near the top of the file:
      AddHandler application/x-httpd-php7 .html .htm
    6. Click the Save button to commit your changes.

    You will now be able to include PHP scripts with your existing HTML that will be executed server side when your site is loaded.



    I am a GoDaddy End User - Just Like You
    Check out my site! | I currently manage over 300 WordPress Websites
    * Please note that I offer free advice on this forum. If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

    Once your issue is resolved,
    please be sure to come back and click accept for the solution

    Get Better Support on the Community Boards!
    Etiquette When Asking for Help from the Community

    Super User III Super User III
    Super User III

    Re: PHP Code Not Showing on My Site

    It depends on the server configuration.  Your local test environment is likely to have different settings than what came default with your hosting account.

    Solution

    Re: PHP Code Not Showing on My Site

    Ok, did a litle more digging and found what works. Have to add this to the htaccess file (this one is for PHP7 specific).

     

    Options +ExecCGI
    FCGIWrapper /usr/local/cpanel/cgi-sys/php7 .html
    AddHandler fcgid-script .html
    AddHandler application/x-httpd-lsphp .html

     

    https://www.godaddy.com/community/VPS-Dedicated-Servers/Running-php-in-html-files/td-p/2776