使用此SQL查询时:
if($count2==0){
//If No Data For Current AF And Date Exists
$sql="INSERT INTO `workhours` (`Date`, `AFNumber`, `Name`, `IN`, `OUT`, `WorkingHours`, `Overtime`, `Status`, `Location`) VALUES('$expldate[1]/$expldate[0]/$expldate[2]', '$afnbr', '$name', '$firstin[0]:$firstin[1]', '$lastout[0]:$lastout[1]', '$totalworkhours:$totalworkmins', '$overtime[0]:$overtime[1]', '$status', '$location')";
if ($con->query($sql) === TRUE) {
echo "Data inserted<br>";
}else {
echo "Error: " . $sql . "<br>" . $con->error."";
}
}else{
//If There Exists Data For Current AF And Date
$sql="UPDATE workhours SET Date='$expldate[1]/$expldate[0]/$expldate[2]', AFNumber='$afnbr', Name='$name', IN='$firstin[0]:$firstin[1]', OUT='$lastout[0]:$lastout[1]', WorkingHours='$totalworkhours:$totalworkmins', Overtime='$overtime[0]:$overtime[1]', Status='$status', Location='$location' WHERE AFNumber='$afnbr'";
if ($con->query($sql) === TRUE) {
echo "Record updated successfully<br>";
} else {
echo "Error updating record: " . $con->error;
}
}
我收到此错误:
注意:未定义的变量:位置 第284行的C:\ xampp \ htdocs \ pp \ login \ code \ upload.php更新错误 记录:您的SQL语法有错误;检查手册 对应于您的MySQL服务器版本,以便使用正确的语法 'IN ='附近:',OUT =':',WorkingHours ='0:0',加班='检查 时间表:错误',状态='Ch'在1AF1110:07/09/2015
有任何帮助吗? 添加IN和OUT
后收到错误答案 0 :(得分:2)
IN
,OUT
是保留关键字。试试 -
`IN`='$firstin[0]:$firstin[1]', `OUT`=':', ...