未捕获的异常' PDOException'消息' SQLSTATE [42S22]:未找到列:1054

时间:2017-05-23 03:54:42

标签: php mysql pdo

我尝试运行以下代码但它收到此错误:

  

致命错误:未捕获的异常' PDOException'消息' SQLSTATE [42S22]:未找到列:1054未知列' ani123'在' where子句''在D:\ xampp \ htdocs \新文件夹\ FINAL PROJECT \ QQUIZ \ admin \ teacher \ t_action.php:44堆栈跟踪:#0 D:\ xampp \ htdocs \新文件夹\ FINAL PROJECT \ QQUIZ \ admin \ teacher \ t_action .php(44):PDO-> exec(' DELETE FROM`qu ...')#1 {main}抛出D:\ xampp \ htdocs \ New文件夹\ FINAL PROJECT \ QQUIZ \第44行的admin \ teacher \ t_action.php

这是我的代码:

$dltQuizesSql = "DELETE FROM `quizes` WHERE `username`=".$_GET['user']; // line 44
$stmt1 = $conn->exec($dltQuizesSql);

这是我桌子的图像:

我的表中存在

username,但我仍然收到错误。

我该如何解决?

1 个答案:

答案 0 :(得分:1)

1)字符串应该用单引号括起来

 "DELETE FROM quizes WHERE username='".$_GET['user']."'"; 

2)删除括号内的分号

( $stmt1 = $conn->exec($dltQuizesSql);)