How to determine if a MySQL update query succeeded when the data passed in the query is the same as what is already in the database?

前端 未结 4 1425
渐次进展
渐次进展 2021-02-20 11:16

Let\'s say you have a form with pre-populated data from your database, and you allow your users to make changes and save the form. If the user clicks the save button without mak

4条回答
  •  你的背包
    2021-02-20 11:55

    Variation 1:

    mysql_query() or die('error');
    

    Variation 2:

    $conn = mysql_query();
    if(!$conn) {//Error code here}
    

    Variation 3:

    try {
      $conn = mysql_query();
      if (!$conn) throw new Exception("mysql Error");
    } catch(Exception $e) {
      echo $e->getMessage();
    }
    

提交回复
热议问题