note 72026 deleted from function.mysql-query by nlopess
| From: | nlopess@php.net | Date: | Fri, 29 Dec 2006 18:15:40 +0000 |
| Subject: | note 72026 deleted from function.mysql-query by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-121017@lists.php.net to get a copy of this message | ||
Note Submitter: brunis at gmail dot com
----
I ran into a problem with this piece of code..
if ( $user->query($sql) ) {
$post = true;
} else {
$post = false;
}
I was assuming mysql_query returned TRUE only if it affected a row.. but it seems to return TRUE, as
long as the SQL is valid.. so my code always returned true..
i fixed it with:
$result = $user->query($sql);
$am = mysql_affected_rows();
if ( $am == 1 ) {
$post = true;
} else {
$post = false;
}
checking the affected rows instead.. hope this helps someone else..