RE: [PHP] sql query successful

From: Date: Wed, 18 Jul 2001 18:48:34 +0000
Subject: RE: [PHP] sql query successful
Groups: php.general 
Request: Send a blank email to php-general+get-58507@lists.php.net to get a copy of this message
> -----Original Message----- > From: Christopher Ostmo [mailto:tech@appideas.com] > Sent: Wednesday, July 18, 2001 2:43 PM > To: php-general@lists.php.net > Subject: Re: [PHP] sql query successful > > > Your statement above is checking to see if the fact that $sql > is equal to mysql_query("SELECT * FROM table ORDER BY rand()") > is TRUE, but you're using an assignment operator (=) and not a > comparison operator (==), so it should always return FALSE. (Can > you use an assignment operator in an if() statement?) Actually, you can. (See http://www.php.net/manual/en/language.operators.assignment.php) An assignment operation will return the value that was assigned. Thus, if we have if ($sql = mysql_query($query_string)) and the mysql_query call returns a non-false value, the entire expression will evaluate to true. --- 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 (#58507) next »