我收到以下错误:
致命错误:未捕获的异常' PDOException'与消息 ' SQLSTATE [42000]:语法错误或访问冲突:1064您有 SQL语法错误;查看与您的手册相对应的手册 MySQL服务器版本,使用接近' High_Priority =的正确语法 '否',Private_Locate ='否',Ticket_Revision_Number =' 1' '在第8行' 在/home3/cmschu/public_html/pl/811/edit_ticket_submit.php:102堆栈 追踪:#0 /home3/cmschu/public_html/pl/811/edit_ticket_submit.php(102): 抛出PDOStatement-> execute()#1 {main} 第102行/home3/cmschu/public_html/pl/811/edit_ticket_submit.php
运行以下PDO语句时:
// configuration
include('811_common.php');
date_default_timezone_set('America/Los_Angeles');
// new data
$Member_Code = $_POST['Member_Code'];
$State = $_POST['State'];
$Ticket_Number = $_POST['Ticket_Number'];
$Start_Date = $_POST['Start_Date'];
$Arrive = $_POST['Arrive'];
$Depart = $_POST['Depart'];
$COB01_WATER = $_POST['COB01_WATER'];
$COB01_SEWER = $_POST['COB01_SEWER'];
$COB01_STORM = $_POST['COB01_STORM'];
$COB01_LIGHTS = $_POST['COB01_LIGHTS'];
$COB01_HOURLY = $_POST['COB01_HOURLY'];
$COB01_SV = $_POST['COB01_SV'];
$COB01_ONCALL = $_POST['COB01_ONCALL'];
$NEWB01_POTABLE_WATER = $_POST['NEWB01_POTABLE_WATER'];
$NEWB01_REUSE_WATER = $_POST['NEWB01_REUSE_WATER'];
$NEWB01_DATA_COM = $_POST['NEWB01_DATA_COM'];
$NEWB01_SL = $_POST['NEWB01_SL'];
$Locate_Code = $_POST['Locate_Code'];
$Ticket_Status = $_POST['Ticket_Status'];
$Int_Note = $_POST['Int_Note'];
$Bill_Status = $_POST['Bill_Status'];
$High_Priority = $_POST['High_Priority'];
$Private_Locate = $_POST['Private_Locate'];
$Ticket_Revision_Number = $_POST['Ticket_Revision_Number'];
$db_ID = $_POST['db_ID'];
// query
$sql="UPDATE billing
SET Member_Code = :Member_Code, State = :State, Ticket_Number = :Ticket_Number, Start_Date = :Start_Date, Arrive = :Arrive, Depart = :Depart,
COB01_WATER = :COB01_WATER, COB01_STORM = :COB01_STORM, COB01_SEWER = :COB01_SEWER, COB01_LIGHTS = :COB01_LIGHTS, COB01_HOURLY = :COB01_HOURLY, COB01_SV = :COB01_SV, COB01_ONCALL = :COB01_ONCALL,
NEWB01_POTABLE_WATER = :NEWB01_POTABLE_WATER, NEWB01_REUSE_WATER = :NEWB01_REUSE_WATER, NEWB01_DATA_COM = :NEWB01_DATA_COM, NEWB01_SL = :NEWB01_SL,
Locate_Code = :Locate_Code, Ticket_Status = :Ticket_Status, Int_Note = :Int_Note, Bill_Status = :Bill_Status, High_Priority = :High_Priority, Private_Locate = :Private_Locate, Ticket_Revision_Number = :Ticket_Revision_Number
WHERE db_ID LIKE :db_ID ";
$q = $db1->prepare($sql);
$q->bindValue(':Member_Code', $Member_Code, PDO::PARAM_STR);
$q->bindValue(':State', $State, PDO::PARAM_STR);
$q->bindValue(':Ticket_Number', $Ticket_Number, PDO::PARAM_STR);
$q->bindValue(':Start_Date', $Start_Date, PDO::PARAM_STR);
$q->bindValue(':Arrive', $Arrive, PDO::PARAM_STR);
$q->bindValue(':Depart', $Depart, PDO::PARAM_STR);
$q->bindValue(':COB01_WATER', $COB01_WATER, PDO::PARAM_STR);
$q->bindValue(':COB01_SEWER', $COB01_SEWER, PDO::PARAM_STR);
$q->bindValue(':COB01_STORM', $COB01_STORM, PDO::PARAM_STR);
$q->bindValue(':COB01_LIGHTS', $COB01_LIGHTS, PDO::PARAM_STR);
$q->bindValue(':COB01_HOURLY', $COB01_HOURLY, PDO::PARAM_STR);
$q->bindValue(':COB01_SV', $COB01_SV, PDO::PARAM_STR);
$q->bindValue(':COB01_ONCALL', $COB01_ONCALL, PDO::PARAM_STR);
$q->bindValue(':NEWB01_POTABLE_WATER', $NEWB01_POTABLE_WATER, PDO::PARAM_STR);
$q->bindValue(':NEWB01_REUSE_WATER', $NEWB01_REUSE_WATER, PDO::PARAM_STR);
$q->bindValue(':NEWB01_DATA_COM', $NEWB01_DATA_COM, PDO::PARAM_STR);
$q->bindValue(':NEWB01_SL', $NEWB01_SL, PDO::PARAM_STR);
$q->bindValue(':Locate_Code', $Locate_Code, PDO::PARAM_STR);
$q->bindValue(':Ticket_Status', $Ticket_Status, PDO::PARAM_STR);
$q->bindValue(':Int_Note', $Int_Note, PDO::PARAM_STR);
$q->bindValue(':Bill_Status', $Bill_Status, PDO::PARAM_STR);
$q->bindValue(':High_Priority', $High_Priority, PDO::PARAM_STR);
$q->bindValue(':Private_Locate', $Private_Locate, PDO::PARAM_STR);
$q->bindValue(':Ticket_Revision_Number', $Ticket_Revision_Number, PDO::PARAM_STR);
$q->bindValue(':db_ID', $db_ID, PDO::PARAM_INT);
$q->execute();
?></span>
答案 0 :(得分:1)
HIGH_PRIORITY
是一个MySQL保留字。
https://dev.mysql.com/doc/refman/5.7/en/keywords.html
如果要将其用作标识符(例如列的名称),则必须正确转义对标识符的引用。正常的MySQL模式是将标识符包含在反引号字符中。例如:
, Bill_Status = :Bill_Status
, `High_Priority` = :High_Priority
, Private_Locate = :Private_Locate