dqby43944 2017-05-23 03:54
浏览 188
已采纳

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

This question already has an answer here:

I tried to run the following code but it gets this error:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ani123' in 'where clause'' in D:\xampp\htdocs\New folder\FINAL PROJECT\QQUIZ\admin\teacher\t_action.php:44 Stack trace: #0 D:\xampp\htdocs\New folder\FINAL PROJECT\QQUIZ\admin\teacher\t_action.php(44): PDO->exec('DELETE FROM `qu...') #1 {main} thrown in D:\xampp\htdocs\New folder\FINAL PROJECT\QQUIZ\admin\teacher\t_action.php on line 44

Here is my code:

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

And here is an image of my table:

username exists in my table but I still get the error.

How can I solve it?

</div>
  • 写回答

1条回答 默认 最新

  • dongqiao5573 2017-05-23 03:58
    关注

    1) string should be enclosed by single quotes

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

    2) Remove semicolon inside the brackets

    ( $stmt1 = $conn->exec($dltQuizesSql);)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services