MySQL warning about INSERT INTO VALUES()

Lately, just on my home computer, I get this warning when I use INSERT( …) VALUES(…)

Just as an example, say I have:

$mysql = 'INSERT INTO allstudentsAnswers20BEHW(studentnr, name, weeknr, score, Answer1, Answer2, Answer3) VALUES(?, ?, ?, ?, ?, ?, ?)
 $mystmt = $pdo->prepare($mysql);
 $mystmt->execute([$studentnr, $studentname, $weeknr, $score, $q1, $q2, $q3)

This works OK, but I get this message:

Warning: #1287 ‘VALUES function’ is deprecated and will be removed in a future release. Please use an alias (INSERT INTO … VALUES (…) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead.

What should the new command look like??

I do not get this on my webpage , at least I haven’t noticed it.

That’s a first? :thinking: The only thing I can think of is there isn’t a space between VALUES( and VALUES ( and it’s treating it like a function.

 $sql = 'INSERT INTO allstudentsAnswers20BEHW(studentnr, name, weeknr, score, Answer1, Answer2, Answer3) VALUES (?, ?, ?, ?, ?, ?, ?)
 $stmt = $pdo->prepare($sql);
 $stmt->execute([$studentnr, $studentname, $weeknr, $score, $q1, $q2, $q3])

Just notice you didn’t have an end bracket.
Personally I think standard naming conventions of variables makes it easier to read the code, but it’s a coder’s preference. I am just giving my .02 cents. :wink:

Here’s something I threw together earlier in the month that might help you out? https://www.miniaturephotographer.com/index.php?page=1

This error/warning doesn’t actually apply to what you are doing. However, because the programmer at MySql didn’t put it into the correct context, which is only for the ON DUPLICTE KEY UPDATE portion of a query, you are seeing it.

If you insert a space between the VALUES and the ( and/or use the VALUE (no S) keyword, the warning should (untested) go away.

Sponsor our Newsletter | Privacy Policy | Terms of Service