gpt4 book ai didi

php - MySQL 中的插入失败错误

转载 作者:行者123 更新时间:2023-11-29 01:19:14 28 4
gpt4 key购买 nike

while($row=mysql_fetch_array($result2)){    
//return $row['ProjectID'];
$sql="INSERT INTO `tycodashboard` (ProjectID,DesignationID,ReqcompID,IntOrgID,FinishedTimeID,ProjectStatusID,PhaseID
) VALUES('{$row['ProjectID']}','$pm,'$req','$initiating,'$initiating','$ftime,'$ProjectStatus,'$Phase)";
$result=mysql_query($sql);
if(!$result){
if(mysql_errno() == ER_DUP_ENTRY){
throw new Exception("INSERT FAILED.\n\nThe database already contains a Project with the Project Name \"$ldesc\", please pick another.");
}else{
throw new Exception("INSERT FAILED.\n\n".mysql_error());
}
}
}//exits

INSERT FAILED.

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 '3','2,'2','2,'2,'3)' at line 2

最佳答案

从错误消息中可以看出,您遗漏了一大堆引号:

'3','2,'2','2,'2,'3

尝试在缺少的地方添加引号,看看是否有帮助:

$sql="INSERT INTO `tycodashboard` (ProjectID,DesignationID,ReqcompID,IntOrgID,FinishedTimeID,ProjectStatusID,PhaseID
) VALUES ('{$row['ProjectID']}','$pm','$req','$initiating','$initiating','$ftime','$ProjectStatus','$Phase')";

关于php - MySQL 中的插入失败错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2670593/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com