Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause''

半腔热情 提交于 2019-12-02 17:45:45

问题


<?php 
require 'database.php';
$id = 0;

if ( !empty($_GET['user_id'])) {
    $id = $_REQUEST['user_id'];
}

if ( !empty($_POST)) {
    // keep track post values
    $id = $_POST['user_id'];

    // delete data
    $pdo = Database::connect();
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $sql = "DELETE FROM admin  WHERE id = ?";  ===> Wrong on here.. //LINE18
    $q = $pdo->prepare($sql);
    $q->execute(array($id));
    Database::disconnect();
    header("Location: index.php"); 

} 

?>

somebody can help me? why i got Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]

sorry my english is bad, thanks


回答1:


The error message indicates that the table admin in your database does not have a column called id. You need to check what columns are available in the table, but without more information (such as the table definition), I can't be more help.



来源:https://stackoverflow.com/questions/28454731/fatal-error-uncaught-exception-pdoexception-with-message-sqlstate42s22-co

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!