2012-01-18 2 views
0

내 코드가 어떤 이유로 오류가 발생하고 이유를 파악할 수 없습니다.부적절한 MySQL 구문?

INSERT INTO organization (org_name, add_1, add_2, city, state, zip, url, email, phone, contact, hours, file_loc, notes, description, group) VALUES('testmi', '333', '', '', 'MI', '', 'www.blah.com', '', '888-999-2222', '', '', '', '', '', 'Michigan')QUERROR 3You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group) VALUES('testmi', '333', '', '', 'MI', '', 'www.blah.com', ''' at line 1 

을 그리고 여기에 코드입니다 : 다음은 오류입니다

$sqlInsertOrg = "INSERT INTO organization (org_name, add_1, add_2, city, state, zip, url, email, phone, contact, hours, file_loc, notes, description, group) 
      VALUES('".$org_name."', '".$add_1."', '".$add_2."', '".$city."', '".$state."', '".$zip."', '".$url."', '".$email."', '".$phone."', '".$contact."', '".$hours."', '".$file_loc."', '".$notes."', '".$description."', '".$group."')"; 
+0

". $ var." "$ var"를 수행하면 모든 것을 한 줄에 모두 담아 가독성을 높일 수 있습니다. –

답변

4

GROUP는 MySQL은 예약 된 키워드입니다. 역 따옴표 (`)로 이스케이프하면 괜찮을 것입니다.

INSERT INTO organization (org_name, ... `group`) ...