Re: invalid argument supplied for foreach()

From: Date: Tue, 18 Feb 2003 07:13:06 +0000
Subject: Re: invalid argument supplied for foreach()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-135960@lists.php.net to get a copy of this message
At 05:27 18.02.2003, Lynn said: --------------------[snip]-------------------- >Could anyone please tell me what a valid argument would be in this script? > > >error message >Warning: Invalid argument supplied for foreach() in >/home1/domains/$domain/htdocs/image.php on line 334 > > >line 323-343 > > >$dg = opendir("$thumb"); >echo "<HTML><HEAD><TITLE>$title</TITLE><META NAME=Description >CONTENT='Page >Generated with ScriptCoders AutoThumbs V2.01 >http://www.scriptcoders.com'></HEAD>"; >PrintHeader(); >echo "<center><br><img >src=/content/images/br.gif><br><br>"; >echo "<center><table border=0 width=90% ALIGN=CENTER VALIGN=CENTER><tr >ALIGN=CENTER VALIGN=CENTER><td ALIGN=CENTER VALIGN=CENTER>"; >while ( gettype($file = readdir($dg)) != boolean ) > { > if (! is_dir("$file")) >$retVal[count($retVal)] = $file; >} >closedir($dg); >foreach ($retVal as $newFile) --------------------[snip]-------------------- You never explicitly "declare" $retval here. In case the while-loop is executed, $retval is implicitly initialized as an array, but if the while-loop fails to run, $retval is undefined, hence the error. -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/

« previous php.general (#135960) next »