Relative URLs and all that mishmash...
From: Joseph Ellis (jandellis_at_cox.net)
Date: 07/30/04
- Next message: Hayden Kirk: "Re: PHP5 errors ..."
- Previous message: Anthony M. Saffer: "Question about grouping, catagorization, etc..."
- Next in thread: steve: "Re: Relative URLs and all that mishmash..."
- Reply: steve: "Re: Relative URLs and all that mishmash..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 29 Jul 2004 22:11:38 -0500
Hello all,
I'm having a hard time dealing with relative paths in PHP. Say I have
a directory structure that looks like:
+HOME
|
|---+SUBDIR
|
|---+IMAGES
In the HOME directory, I have a PHP script, "logo.php", which
includes:
foreach(glob("images/*.jpg") as $filename) {
$files[] = $filename;
}
Then it goes on to pick a random .jpg file from the array for display
on a web page. This works fine.
Now, say I have a script "subdir.php" in the SUBDIR directory which
includes logo.php:
include("../logo.php");
When this subdir.php script gets past the foreach loop, I get the
following error:
Warning: array_rand(): First argument has to be an array in
C:\xampp\htdocs\new\logo.php on line 12
This tells me that the $files array is empty, and it has something to
do with subdir.php being in the SUBDIR directory rather than HOME.
Am I doing something wrong? What can I do to get logo.php to work
properly regardless of where it's being called from?
Thanks for any suggestions,
Joseph
- Next message: Hayden Kirk: "Re: PHP5 errors ..."
- Previous message: Anthony M. Saffer: "Question about grouping, catagorization, etc..."
- Next in thread: steve: "Re: Relative URLs and all that mishmash..."
- Reply: steve: "Re: Relative URLs and all that mishmash..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|