Let me start off by saying that if my question has already been answered, please point me to the answer as I have been unable to locate a viable solution to my problem.
I am trying to insert information submitted from a form into a table within a database. I am able to connect to the database just fine but when I try to run the INSERT
SQL command, it spits out and error message. All that I am getting is: "Error: INSERT INTO 008181 (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 ('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', 'yes', '34', '34', '', '', '', '', '', '', '', '', '', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes')
1064 ". Part of my INSERT
command is being filled in by a PhP variable, however the variable is putting the correct information into the command.
The following is my php commands:
$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);
}
I am not sure of where my sql is going wrong as this error is only spitting out the same information which I am putting into the command.
Again, I am able to connect to the database just fine, and the database has tables set up to correspond to all possible $storeNumber
s that can be selected within the submitting form. When setting up the command at first, I did not have any form of quot marks around the column names within the table. I have even tried to grab the sql code directly from phpmyadmin and only change the referring table name to the corresponding variable.