Connecting Tech Pros Worldwide Forums | Help | Site Map

mysql_query return value confusion

Bill
Guest
 
Posts: n/a
#1: Jul 23 '05
I have the following line in a php script
$queryDeletePosition = mysql_query("DELETE FROM `Position` WHERE
`stockID` = '$existStockID' AND `userID`='$userID' AND `groupID`='$groupID'
LIMIT 1 ", $connMydb) or die(mysql_error());

It works fine . The entry I want deleted from the database is deleted.
However $queryDeletePosition value is 1, confirmed by
echo"<script> alert(\" result is $queryDeletePosition \");
</script>";
And after $num_rows = mysql_affected_rows();
$num_rows value is 0, confirmed by
echo"<script> alert(\" num rows is $num_rows \"); </script>";

As I understand if the DELETE command to mysql is successful mysql_query()
should return 0 and mysql_affected_rows() should return a value greatrer
than 0.

Can someone help me understand what is happening here? I need to be able to
get a correct value from one of the functions to alert the user.

TIA
Bill




Closed Thread