Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP POD在更新后返回0个受影响的行_Php_Mysql - Fatal编程技术网

PHP POD在更新后返回0个受影响的行

PHP POD在更新后返回0个受影响的行,php,mysql,Php,Mysql,我正在编写一个脚本,它使用文件名和更新用户信息,下面是代码片段 $fname = $_FILES['photo']['name']; $userId = cleanString($_POST['uid']); $sql= 'UPDATE `contacts` SET `imgpath` = ? WHERE `contact_id` = ?'; $stmt = $DBH->prepare($sql); if($stmt === false) { trigger_er

我正在编写一个脚本,它使用文件名和更新用户信息,下面是代码片段

$fname =  $_FILES['photo']['name'];
$userId = cleanString($_POST['uid']);
$sql= 'UPDATE `contacts` SET `imgpath` = ? WHERE `contact_id` = ?';
$stmt = $DBH->prepare($sql);
    if($stmt === false) {
        trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $DBH->error, E_USER_ERROR);
    }
$stmt->bind_param('ss',$fname , $userId);

$stmt->execute();
echo $stmt->affected_rows;
$stmt->close();

运行脚本后,它将显示0个受影响的行。运行脚本时,我没有收到任何错误。

检查时更新是否发生在数据库中?@Ghost Nope dbfield仍然为空您真正想做什么?使现代化还是插入?如果该行仍然不存在,则不会有受影响的行使用$stmt->rowCount;