Hello, i'm having some problem when comparing date (from user input) with the date inside database. The format of both dates are the same (YYYY-MM-DD). This is the error it shows

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 'WHERE date = 2012-08-30' at line 1

and the code

mysql_query("INSERT INTO $attlist ($tempName) VALUES ($tempValue) WHERE date = '$date' ") or die(mysql_error());

Really appreciate your help. Thanks

date is reserved word you shouldn't use it as a field name
you can still get around this by wrapping date in backticks

`date`='$date'

Changed to

`date` = '$selected_date'

still getting the same syntax error.

Thanks for the reply though

Member Avatar for diafol

You sure you used backticks and not single quotes? Sorry, just asking.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.