Undefined variables
| From: | Alf Stockton | Date: | Fri, 08 Sep 2006 15:09:43 +0000 |
| Subject: | Undefined variables | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-27134@lists.php.net to get a copy of this message | ||
In this little script:-
<?php
#This script has been developped by Nenad Motika [nmotika@bezveze.com]
#Please feel free to use it and to contact me for any reason
session_start();
//read folder
$folder=opendir(".");
while ($file = readdir($folder))
$names[count($names)] = $file; // <----- Line 8
closedir($folder);
//sort file names in array
sort($names);
//remove any non-images from array
$tempvar = $i = 0;
for ($i=0;$names[$i];$i++) { // <----- Line 14
$ext=strtolower(substr($names[$i],-4));
if ($ext==".jpg"||$ext==".gif"||$ext=="jpeg"||$ext==".png") {
$names1[$tempvar]=$names[$i];
$tempvar++;
}
}
$Count = $_SESSION['Picture'];
--$Count;
// echo 'Count = '.$Count.' $tempvar = '.$tempvar;if ($Count == 0) {
$Count = $tempvar-1;
}
$_SESSION['Picture'] = $Count;
$slika=$names1[$Count];
//image dimensions
$dimensions = GetImageSize($slika);
if (isset($HTTP_GET_VARS["pic"])){header ("Location: $slika");}
else {echo "<img src=\"$slika\" $dimensions[3]>";}
?>
I keep getting:-
[Fri Sep 08 17:04:57 2006] [error] [client 127.0.0.1] PHP Notice: Undefined variable: names in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\events\\adverts\\ridtoo.php on line 8, referer: http://localhost/events/rotate.shtml
[Fri Sep 08 17:04:57 2006] [error] [client 127.0.0.1] PHP Notice: Undefined offset: 13 in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\events\\adverts\\ridtoo.php on line 14, referer: http://localhost/events/rotate.shtml
Please tell me what evil I have committed to cause this?
--
Regards,
Alf Stockton www.stockton.co.za
Lay on, MacDuff, and curs'd be him who first cries, "Hold, enough!".
-- Shakespeare
My email disclaimer is available at www.stockton.co.za/disclaimer.html