View Full Version : Trying to get <?php include("includes/file.php"); ?> to work
murphyslaw
10-20-2009, 03:00 PM
I can't seem to get the include function to work.
On all pages of my website I have 4 or 5 includes.
All includes are something like file-1.php, file-2.php etc and they reside in public_html/add-on-domain/includes/file-1.php
All my pages are .html and I am using the following in the html pages:
<?php include("includes/file-1.php"); ?>
I have tried:
<?php include("/includes/file-1.php"); ?>
(Slash before includes)
<!--#include virtual="/includes/file-1.php" -->
(Also tried renaming file-1.php to file-1.html)
Anyone know the solution to this?
<?php include("includes/file-1.php"); ?> .. This used to work on my previous host so not sure what's going on.
Thanks
MrDelish
10-20-2009, 03:12 PM
Try adding a handler for "server-parsed" applied to the PHP extension. You can either do this under cPanel -> Advanced -> Apache Handlers or by adding the following line to your .htaccess file:
Addhandler application/x-httpd-php .php
murphyslaw
10-20-2009, 03:30 PM
Hi MrDelish,
In cPanel -> Advanced -> Apache Handlers -> Apache Handler List there is already application/x-httpd-php5 (Handler) ... .php (Extension(s))
Is this the same thing?
MrDelish
10-20-2009, 03:39 PM
Whoops... I copied the wrong line. Here's the right one:
AddHandler server-parsed .php
felgall
10-20-2009, 04:33 PM
Whoops... I copied the wrong line. Here's the right one:
AddHandler server-parsed .php
It should only need that one if you are using the SSI include (the third one tried) in place of the PHP include.
What error message do you get when you try the first two versions of the command? Does adding a dot before the leading slash help?
murphyslaw
10-20-2009, 04:44 PM
Still no luck with this...
My htaccess file in public_html/ has the following in it:
# Use PHP5 as default
AddHandler application/x-httpd-php5 .php
AddHandler server-parsed .php
cPanel > Software / Services > PHP Config is set to run as PHP5
cPanel > Advanced > Apache Handlers has the following:
User Defined Apache Handlers
Handler > server-parsed | Extension(s) > .php
System Apache Handlers
Handler > cgi-script | Extension(s) > .cgi .pl
Handler > server-parsed | Extension(s) > .shtml
The code I'm using in public_html/add-on-domain/index.html page to call the include is:
<?php include("includes/file-1.php"); ?>
(Tried with / in front of includes, tried with ../ in front of includes)
Includes live in public_html/add-on-domain/includes/file-1.php
Don't really know what else to try ...
murphyslaw
10-20-2009, 04:52 PM
What error message do you get when you try the first two versions of the command? Does adding a dot before the leading slash help?
Not getting any errors (in the browser or an error log on the server)
php.ini is set to:
error_reporting = E_ALL & ~E_NOTICE
display_errors = On
log_errors = On
Adding a dot before the slash doesn't help either
murphyslaw
10-20-2009, 05:13 PM
As an experiment I tried a test install of wordpress from cPanel > Software / Services > Wordpress and I get the following message:
"Server Configuration Bad
Your server is having difficulties processing PHP requests. Please contact your server admin or web host about possible resolutions."
So it looks like it's a server issue .. sigh
<?php phpinfo(); ?>
Doesn't work either .. asks me to download it
Server status is showing:
mysql (5.0.81-community-log) | failed
felgall
10-20-2009, 06:38 PM
You might try using live chat to check with support as to what is happening with your server.
murphyslaw
10-20-2009, 06:42 PM
I spoke to live chat and commented out:
AddHandler server-parsed .php
From public_html/.htaccess
This at least allowed php files to work.
Still, my includes were not working.
Anyway, after a lot of searching I found the solution .. my public_html/.htaccess now reads:
# Use PHP5 as default
AddHandler application/x-httpd-php5 .php
AddType application/x-httpd-php .html .htm
AddHandler application/x-httpd-php .html .htm
Thanks to all for your input.
felgall
10-20-2009, 07:27 PM
All my pages are .html
I think we all missed that small piece of your first comment.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.