mysql_query return value confusion

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bill

    mysql_query return value confusion

    I have the following line in a php script
    $queryDeletePos ition = mysql_query("DE LETE FROM `Position` WHERE
    `stockID` = '$existStockID' AND `userID`='$user ID' AND `groupID`='$gro upID'
    LIMIT 1 ", $connMydb) or die(mysql_error ());

    It works fine . The entry I want deleted from the database is deleted.
    However $queryDeletePos ition value is 1, confirmed by
    echo"<script> alert(\" result is $queryDeletePos ition \");
    </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



Working...