首先我要说的是,如果我的问题已经得到解答,请指出我的答案,因为我无法找到解决问题的可行办法。
我正在尝试将表单中提交的信息插入到数据库中的表中。我能够很好地连接到数据库,但是当我尝试运行INSERT
SQL命令时,它会吐出并显示错误消息。我得到的只是:“错误:INSERT INTO 008181(userID,校准,dayName,日期,时间,bottomAirTemp,topAirTemp,meatTemp,cheeseTemp,walkinTemp,refrig1Temp,refrig2Temp,refrig3Temp,freeze1Temp,freeze2Temp,freeze3Temp,saladAirTemp,saladCheeseTemp, wingTemp,sauceTemp,buffPizzaTemp,hotHold,pizzaTemp,pastaTemp,topOvenTemp,topOvenSpeed,centerOvenTemp,centerOvenSpeed,bottomOvenTemp,bottomOvenSpeed,greenPepperDate,mushroomDate,onionDate,approvedProduct,expiredProduct,rawZoneProcess,fifoProcess,produceWashed,hotWater,ppmLevel,highTempWasher,lowTempWasher,chemicalsStored, illTeamMembers,handWashing,waterTemp,sinksStocked,hairRestraints,pestProvention)VALUES('GW','yes','Sunday','March 12','2:34:24 PM','34','34','34 ','34','34','34','34','34','34','34','34','34','34','34','34', '34','是','34','34','','','','','','','','','','是','是' ,'是','是','是','是','是','是','是','是','是','是','是','y es','yes','yes')
1064“。我的INSERT
命令的一部分由PhP变量填充,但变量正在将正确的信息输入命令。
以下是我的php命令:
$sql = "INSERT INTO $storeNumber (userID, calibration, dayName, date, time, bottomAirTemp, topAirTemp, meatTemp, cheeseTemp, walkinTemp, refrig1Temp, refrig2Temp, refrig3Temp, freeze1Temp, freeze2Temp, freeze3Temp, saladAirTemp, saladCheeseTemp, wingTemp, sauceTemp, buffPizzaTemp, hotHold, pizzaTemp, pastaTemp, topOvenTemp, topOvenSpeed, centerOvenTemp, centerOvenSpeed, bottomOvenTemp, bottomOvenSpeed, greenPepperDate, mushroomDate, onionDate, approvedProduct, expiredProduct, rawZoneProcess, fifoProcess, produceWashed, hotWater, ppmLevel, highTempWasher, lowTempWasher, chemicalsStored, illTeamMembers, handWashing, waterTemp, sinksStocked, hairRestraints, pestProvention)
VALUES ('$userID', '$calibration', '$dayName', '$date', '$time', '$bottomAirTemp', '$topAirTemp', '$meatTemp', '$cheeseTemp', '$walkinTemp', '$refrig1Temp', '$refrig2Temp', '$refrig3Temp', '$freeze1Temp', '$freeze2Temp', '$freeze3Temp', '$saladAirTemp', '$saladCheeseTemp', '$wingTemp', '$sauceTemp', '$buffPizzaTemp', '$hotHold', '$pizzaTemp', '$pastaTemp', '$topOvenTemp', '$topOvenSpeed', '$centerOvenTemp', '$centerOvenSpeed', '$bottomOvenTemp', '$bottomOvenSpeed', '$greenPepperDate', '$mushroomDate', '$onionDate', '$approvedProduct', '$expiredProduct', '$rawZoneProcess', '$fifoProcess', '$produceWashed', '$hotWater', '$ppmLevel', '$highTempWasher', '$lowTempWasher', '$chemicalsStored', '$illTeamMembers', '$handWashing', '$waterTemp', '$sinksStocked', '$hairRestraints', '$pestPrevention')";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br/>" . mysqli_errno($conn);
}
我不确定我的sql出错的地方,因为这个错误只是吐出了我在命令中输入的相同信息。
同样,我能够很好地连接到数据库,并且数据库已设置表格,以对应于可在提交表单中选择的所有可能$storeNumber
。首先设置命令时,表格中的列名称周围没有任何形式的引号。我甚至试图直接从phpmyadmin中获取sql代码,只将引用表名更改为相应的变量。