Reputation: 8277
I use a mysql_affected_rows on a query but it seems to return false even though the query did execute so i'm a bit confused....
This is what i have:
$check = mysql_query("DELETE FROM $table
WHERE name = '".$darray[0]."' AND
password = '".$darray[1]."' AND uid = '$uid'
AND validation = '22'")
or die(mysql_error());
if(mysql_affected_rows($check)>0){
echo 1;
exit;
} else {
echo 'Less than one!';
exit;
}
Any idea why it says less than one - even though my query did actually delete the row ?
Upvotes: 1
Views: 5421
Reputation: 14187
Solved:
Error was that mysql_affected_rows() doesn't expect the query.
More info here: http://php.net/manual/es/function.mysql-affected-rows.php
$check = mysql_query("DELETE FROM $table
WHERE name = '".$darray[0]."' AND
password = '".$darray[1]."' AND uid = '$uid'
AND validation = '22'")
or die(mysql_error());
if(mysql_affected_rows() >0){
echo 1;
exit;
} else {
echo 'Less than one!';
exit;
}
Upvotes: 2
Reputation: 5063
mysql_affected_rows
takes in a connection link, not a query. You can leave that parameter empty and it will refer to the last query executed on that connection.
Upvotes: 2
Reputation: 799062
mysql_affected_rows()
takes the link identifier (i.e., the connection resource), not the result.
Upvotes: 4