2017-10-23 1 views
1

내 웹 사이트에 오류가 있습니다. 오류 :PHP 치명적 오류 : 'SQLSTATE [42000] 메시지와 함께 잡히지 않은 예외'PDOException '

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>"; 
} 

사람이 무슨 잘못 말해 또는하세요 주제에 대한 코드이므로 전체 정보로 편집하십시오.

고마워요!

+2

'get '은 [예약어] (https://dev.mysql.com/doc/refman/5.7/en/keywords.html)입니다. 당신은 그것의 주위에 따옴표 또는 backticks를 사용해야 할 것이다. 컬럼 별칭이므로 둘 중 하나를 사용해야합니다. – aynber

+1

[MySQL에서 작은 따옴표, 큰 따옴표 및 백틱을 사용하는 경우] 가능한 복제본 (https://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-backticks- in-mysql) – aynber

답변

0

SQL에서 getreserved 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)); 
관련 문제