PDO error: “ SQLSTATE[HY000]: General error ” When updating database

德克斯特 2017-08-11

Code:

try { $stmt = $pdo->prepare("UPDATE $page SET $section = :new_content WHERE $section = '$old_content'"); $stmt->execute(array( 'new_content' => $new_content )); $result = $stmt->fetchAll(); echo "Database updated!"; } catch(PDOException $e) { echo 'ERROR UPDATING CONTENT: ' . $e->getMessage(); }

Error: ERROR UPDATING CONTENT: SQLSTATE[HY000]: General error

Answers

You do not use fetchAll(),as in

$result = $stmt->fetchAll();

with update or insert queries. Removing this statement should rectify the problem.

来源:https://stackoverflow.com/questions/12979510/pdo-error-sqlstatehy000-general-error-when-updating-database

查看更多主题的豆瓣日记和相册

德克斯特
作者德克斯特
260日记 8相册

全部回应 0 条

添加回应

德克斯特的热门日记

值得一读

    豆瓣
    我们的精神角落
    免费下载 iOS / Android 版客户端
    App 内打开