mySQL inserts just stopped inserting (PHP)
Was just recently alerted to the fact the student grades were being calculated, but not inserted into a mysql database. I didn't have error reporting turned on, so that was my first step. I added the "or die" line to the query.
mysql_query($my_new_query) or die(mysql_error()."<br>Red alert, score not saved!");
This got me some good information, namely the following alert:
Incorrect integer value: '' for column 'uniquekey' at row 1
$my_new_query = "INSERT INTO grading_table VALUES ('$name','$score', ' ')";
The above code worked for a long time-- I just submitted an empty string to the mySQL database, and it did it's auto-increment auto-magically. Something must have recently changed with my shared hosting provider, because this no longer worked. Look what does though:
$my_new_query = "INSERT INTO grading_table VALUES ('$name','$score', NULL)";
Explicitly defining the NULL seems to make the new database happy and my scores are being saved again.
This is an old program, being retired soon, which is why I haven't updated the mysql_query PHP command to a more modern one.
Aucun trackbacks pour l'instant