Undefined variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In this little script:-

<?php
#This script has been developped by Nenad Motika [nmotika@xxxxxxxxxxx]
#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

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux