Jump to content

Error using CURDATE()


Eskimo887

Recommended Posts

I have a join form on my website which adds the current date to the database so I know when people have joined.

For this, my INSERT query looks like:

[code] $sql = "INSERT INTO roster SET " . "first_name='$first', " . "last_name='$last', " . "email='$email', " . "password='$password', " . "join=CURDATE()";[/code]

But, when I submit the form, I get the error:

[quote]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 'join=CURDATE()' at line 1[/quote]

What is wrong with my syntax, as I have another INSERT query that uses exactly the same thing.
Link to comment
https://forums.phpfreaks.com/topic/15243-error-using-curdate/
Share on other sites

[quote author=Eskimo887 link=topic=101366.msg401099#msg401099 date=1153480619]
I have a join form on my website which adds the current date to the database so I know when people have joined.

For this, my INSERT query looks like:

[code] $sql = "INSERT INTO roster SET " . "first_name='$first', " . "last_name='$last', " . "email='$email', " . "password='$password', " . "join=CURDATE()";[/code]

But, when I submit the form, I get the error:

[quote]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 'join=CURDATE()' at line 1[/quote]

What is wrong with my syntax, as I have another INSERT query that uses exactly the same thing.
[/quote]

"join" is a [url=http://dev.mysql.com/doc/refman/4.1/en/reserved-words.html]reserved word[/url] you can either surround the column name with backticks (``) or change the column name.

I'd recommend you change the column name.
Link to comment
https://forums.phpfreaks.com/topic/15243-error-using-curdate/#findComment-61633
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.