Re: File_exists function question.

From: Date: Fri, 16 Feb 2001 07:42:20 +0000
Subject: Re: File_exists function question.
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-40117@lists.php.net to get a copy of this message
Gerry, the following is your problem: you fetch a row from the query result in each iteration: > while ($row = mysql_fetch_array($sql_result)) { and the use the value of $ID. > $fn = "/images/$ID.jpg"; you need to fetch the value of the ID column into the ID variable before. Assuming your select looks like the following: select ID, description, blah from images; you need to do something like $ID = $row[0]; $description = $row[1]; $blah = $row[2]; Or you just change your while condition to while( list( $ID, $description, $blah ) = mysql_fetch_row( $result ) ) { Cheers, Ben Gerry wrote: > > Hello again: > > Ben Peter wrote: > > > > Gerry, > > > > could you give us a bit more code, esp. the while or for loop that > > surrounds the code you have quoted? > > > > Cheers, > > Ben > > Sorry for the confusion, and yes I did mispelled camera in english. Here > is more of my sloppy code. I might have an extra }...not sure though > since I have anther couple of "ifs" above it. the code works fine, but > not the "(!$file_exists)" part since it seams it is not checking and it > gives the same result all over the table--"no image". I did change > things as suggested I think, but stll get the same thing. > > echo"<table border=\"0\" cellpadding=\"0\" > cellspacing=\"0\" > width=\"100%\" bgcolor=\"ffffff\"\n>"; > echo"<tr>/n"; > > while ($row = mysql_fetch_array($sql_result)) { > > echo"</td><td width=\"20%\" align=\"center\" > valign=\"top\"><font size=\"2\">/n"; > echo $row["name"]; > echo "</font>\n"; > echo"</td><td width=\"20%\" align=\"center\" > valign=\"top\"><font size=\"2\">/n"; > echo $row["Color"]; > echo "</font>\n"; > echo"</td><td width=\"20%\" align=\"center\" > valign=\"top\"><font size=\"2\">"; > echo $row["Size"]; > echo "</font>\n"; > echo"</td><td width=\"20%\" align=\"center\" > valign=\"top\"> </form> "; > echo"<td width=\"20%\" align=\"center\" > valign=\"top\"><font size=\"2\">"; > if (!file_exists($fn)) { > echo "not working yet"; > } else { > echo'<img src=\"http://site.com/images/camera.gif\"éµOîWÍ${ú > ª"á2 Ö>'; > clearstatcache(); > } > echo"<tr><td colspan=\"5\" valign=\"top\"><hr > size=\"1\"></td></tr>"; > } > echo"</table>"; > } > > -- > Gerry Figueroa > -------------- - - - - - * > War does not determine who is right, war determine who is left. > > |XXXXXXX|------^|XXXXXXXXXXXXXXXXXX| > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#40117) next »