Click to See Complete Forum and Search --> : php require files
risklynx
01-31-2008, 02:55 PM
I just installed PHP 4 and PHP 5 on my server. I am trying to run a require format to include different files on a web page. For example:
<?php require("inc/topnav.php");?>
It works on my old server, but not on my new server. Is there something I need to do to get this to work properly that I am missing?
Thanks!
RISKLYNX
jasonahoule
01-31-2008, 03:18 PM
Are you sure you have the correct path to the file? Try using an absolute path like require($_SERVER['DOCUMENT_ROOT'].'/inc/topnav.php')
risklynx
01-31-2008, 04:01 PM
I tried this absolute path and it still didn't work:
<?php require($_SERVER['DOCUMENT_ROOT'].'/inc/topnav.php');?>
jasonahoule
01-31-2008, 06:06 PM
Is the "inc" directory in the root directory?
risklynx
01-31-2008, 10:32 PM
The inc file is just a subfile on the domain. Not sure if it's in the root or not.
GavinPearce
02-01-2008, 03:45 AM
So you have the PHP <?php require("inc/topnav.php");?> in a file in a folder.
Then you have in that folder a folder called inc and inside inc is a file called topnav.php
Is that correct?
jasonahoule
02-01-2008, 03:41 PM
Yeah, it definitely sounds like a problem with the path. Say you have your include in file.php, your directory structure should look like this.
/document root
file.php
/inc
topnav.php