我的网站有错误。 错误:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'get FROM login WHERE user_id = '252' LIMIT 1' at line 1' in /home/tregolap/public_html/config/class/universal.class.php:110 Stack trace: #0 /home/tregolap/public_html/config/class/universal.class.php(110): PDOStatement->execute(Array) #1 /home/tregolap/public_html/ajaxify/profile/profile_banner.php(89): universal->isOnline('252') #2 /home/tregolap/public_html/profile.php(71): include_once('/home/tregolap/...') #3 {main} thrown in /home/tregolap/public_html/config/class/universal.class.php on line 110
universal.class.php代码为:
if ($user != $session) {
$query = $this->db->prepare("
SELECT MAX(login_id) AS get
FROM login WHERE user_id = :id LIMIT 1");
$query->execute(array(":id" => $user));
个人资料横幅错误:
<?php
if($universal->isOnline($get_id)){
echo "<span class='user_status'>online</span>";
}
请有人告诉我哪里出了问题,或者我是否需要针对该主题编辑更多代码,以便我使用完整信息对其进行编辑,
谢谢!
最佳答案
在您的 SQL 中,get
是 reserved words in MySQL 之一.您可以将其更改为非保留字或在其周围加上引号/反引号。
if ($user != $session) {
$query = $this->db->prepare("
SELECT MAX(login_id) AS `get`
FROM login WHERE user_id = :id LIMIT 1");
$query->execute(array(":id" => $user));
关于PHP fatal error : Uncaught exception 'PDOException' with message 'SQLSTATE[42000],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46898452/