View Full Version : Include Script

03-20-2004, 04:26 PM

I've run into a problem! How do you include a php script into files in other directorys?

I must have had a memory blank, I use the following code on my main page and it works fine:

<?php include "php/images.php"; ?>The code loads a script that displays images in the background of a table.

But say i make a new page in a different directory such as http://www.britishrallying.com/feed/index.php, the above code wont work for that! it comes back with the following message:

Warning: Failed opening 'php/images.php' for inclusion (include_path='.:/usr/share/pear') in /home/gareth1980/public_html/feed/index.php on line 50 >Ive tried putting a / before php but to no avail. Like i said my main page works fine: http://www.britishrallying.com/index.php , where am i going wrong?

The code im trying to load is:
//This is the directory route to the folder
//This is a relative link to the directory if it is not in the same directory as the file you are displaying the images on

die("Failed to read directory");
if(ereg($pattern, $s))

//Spit it out
echo "background=\"$directory$image[$randNum]\"";
?>Thanks in advance,

I maybe thick but i get there in the end!:)

03-20-2004, 04:29 PM
../ goes down a directory
/ is from root
./ from current directory

so you need to use


03-20-2004, 04:59 PM
Erm, i feel a bit of a idiot!!!!

Cheers Night fire:)

Sometimes even the small things i forget! Doh

I maybe thick but i get there in the end!:)