开发者

How to know record has been updated successfully in php

$sql = "UPDATE....";

if(mysql_query($sql))
    {
        $_SESSION['Trans']="COMMIT";
        header("location:result.php");
        exit;
    }
    else 
        {
            $_SESSION['Trans']="FAIL";
            $_SESSION['errors'] = "Error: S开发者_如何学JAVAorry! We are unable to update your Profile, Please contact to PNP HelpDesk.";
            header("location:result.php");
            exit;
        }//end  IF

data is getting updated then why compiler is not coming inside IF condition.


mysql_query only returns FALSE on an error condition, rather than if no rows have been updated.

To see if anything has been updated, use mysql_affected_rows, e.g.:

$sql = 'UPDATE ....';
mysql_query($sql);
if (mysql_affected_rows() > 0) { 
  // Success
} else {
  // Failure
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜