user1557314
user1557314

Reputation: 169

simple mysqli NOW() syntax error

sorry, I really don't see it.

I have a mysqli syntax like this:

"UPDATE table
SET
used='1',
ip='".mysqli_real_escape_string($connection,$_SERVER['REMOTE_ADDR'])."',
when=NOW()
WHERE
uid='x3'"

This is my error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near

when=NOW()
WHERE
uid='x3'' at line 6

Upvotes: 0

Views: 33

Answers (1)

Luke Woodward
Luke Woodward

Reputation: 64959

WHEN is a reserved word in MySQL. If you wish to use it as a column name you must surround it in backticks.

In other words, replace

when=NOW()

with

`when`=NOW()

Upvotes: 1

Related Questions