RE: [PHP] while loop- will this work?

From: Date: Thu, 30 Jan 2003 21:40:26 +0000
Subject: RE: [PHP] while loop- will this work?
Groups: php.general 
Request: Send a blank email to php-general+get-133698@lists.php.net to get a copy of this message
> -----Original Message----- > From: SpyProductions Support Team [mailto:support@spyproductions.com] > Sent: Thursday, January 30, 2003 11:57 AM > To: php-general@lists.php.net > Subject: [PHP] while loop- will this work? > > > > > Should this work? Nope...because the value returned by mysql_query() isn't the number of rows returned by the query...it's a pointer to the result set (which could be empty). > $f1 = rand(999,99999999999); > > while($check_sid = mysql_query("SELECT * FROM > that_table WHERE this = > '$f1'")){ > > $f1 = rand(999,99999999999); > > } You'll want something more like... do { $f1 = rand(999,99999999); $check_sid = mysql_query("SELECT * from that_table WHERE this='$f1'")); } while (mysql_num_rows($check_sid)) --- Mark Roedel | "The most overlooked advantage to owning a Systems Programmer | computer is that if they foul up there's no LeTourneau University | law against whacking them around a little." Longview, Texas USA | -- Owen Porterfield

« previous php.general (#133698) next »