So I am coding this new website. But PHP Include function doesn't work on every site. For example here it works : http://www.drixxel.com/tools/index.php But here it doesn't work : http://www.drixxel.com/index.php I am using exact the same code for both pages Anyone got a solution for this?
I assume that the include path was incorrect since they are in different directories but using the same exact code. If in tools/index.php include('filename.php'); PHP: In index.php you would change it to: include('tools/filename.php'); PHP: However, I always advise people to use the absolute path instead of relative ones: $fileName = basename($_SERVER['SCRIPT_FILENAME']); define('BASEPATH',str_replace($fileName,'',$_SERVER['SCRIPT_FILENAME'])); include(BASEPATH . 'filename.php'); PHP:
Yeah well I was using like include("http://www.drixxel.com/include/footer.txt"); PHP: But my webhost didnt allow the http part so this worked include("../include/footer.txt"); PHP: