Hi, sorry new to programming. I am using include files as so in every page i.e. /index.php <?php include("/includes/simon.php"); ?> at root level this include file works fine, With any sub folder i.e. /subfolder/index.php it comes up with an error, Warning: main(/includes/simon.php): failed to open stream: No such file or directory in etc etc \subfolder\index.php on line 15 I thought putting the inital forward slash "/" would work? any quick fix other than putting a "../" in all the subfolder files? Many thanks for reading, Simon
<?php include("includes/simon.php"); ?> will works...!, if you are in forder x, the includes folder must be with in x,
Another solution - absolute path via $_SERVER['DOCUMENT_ROOT'] <?php define('APPLICATION_PATH', $_SERVER['DOCUMENT_ROOT']); include( APPLICATION_PATH."/includes/simon.php"); ?> Don't use $_SERVER['DOCUMENT_ROOT'] direct in the include(), some day it can make troubles.
Depends on your php settings i believe, but you can even include php files on other sites. Anyways, just do the full path to the file. Like include "/home/username/public_html/folder/file.php";