PHP/mysql get number of affected rows of UPDATE statement

前端 未结 5 1062
一整个雨季
一整个雨季 2020-12-09 19:36

With php/mysql how can i get the number of rows that a query affected?

what i tried so far:

$result = mysql_query($q);
mysql_num_rows($result);
         


        
5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-09 20:21

    clamp,

    you need to supply a resource to mysql_affected_rows, not a result record. See the links that the others have posted for additional information.

    $link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
    $result = mysql_query($q);
    echo mysql_affected_rows($link);
    

提交回复
热议问题