본문 바로가기
MySql

MySQL 'SQLSTATE [42000'메시지와 함께 포착되지 않은 예외 'PDOException'

by 베이스 공부 2020. 12. 19.
반응형

CSV에서 테이블을 업데이트하려고합니다. 행을 삽입하려고 할 때 다음 오류가 나타납니다. 다른 쿼리는 동일한 루프에서 진행되지만 특정 루프에서 중지됩니다.

모든 값이 DB 테이블과 정확히 일치하는지 확인했습니다.

나는 무엇이 문제가 될 수 있는지에 대한 아이디어가 없습니다. 어떤 제안?

검색어

INSERT INTO user_interests (member_num,ABU,ADD,ADOP,ANO,ANX,BER,BULL,COMP,CONF,CONT,CUL,DEP,DIS,DOM) VALUES (:member_num,:ABU,:ADD,:ADOP,:ANO,:ANX,:BER,:BULL,:COMP,:CONF,:CONT,:CUL,:DEP,:DIS,:DOM)

오류

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 'ADD,ADOP,ANO,ANX,BER,BULL,COMP,CONF,CONT,CUL,DEP,DIS,DOM) VALUES ('5323',1,1,1,1' at line 1' in /Applications/XAMPP/xamppfiles/htdocs/ukcp/phpLibraries/users/userPopulateInts.php:45 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/ukcp/phpLibraries/users/userPopulateInts.php(45): PDOStatement->execute() #1 /Applications/XAMPP/xamppfiles/htdocs/ukcp/userprofile.php(14): userPopulateInts->ints1() #2 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/ukcp/phpLibraries/users/userPopulateInts.php on line 45

코드

  if ( !empty($int) && !empty($intColon) ) {
                    $sql = 'INSERT INTO user_interests (member_num,'. implode(",", $int) .') VALUES (:member_num,'. implode(",", $intColon) .')';
                    $dbQuery = $this->db()->prepare($sql);
                    echo $sql ."<br>";
                    $dbQuery->bindValue(":member_num", $data[0], PDO::PARAM_INT);
                    foreach ($intColon as $val) {
                        $dbQuery->bindValue($val, 1, PDO::PARAM_INT);
                    }

                    $dbQuery->execute();
                }

 

해결 방법

 


INSERT INTO user_interests (member_num, ABU, `ADD`, ...

 

참조 페이지 https://stackoverflow.com/questions/19833881

 

 

반응형

댓글