I have this piece of code which i use to compare a timestamp field with a date i’ve selected before!
But i get an error in syntax..
Howcome?
$query = sprintf( 'SELECT * FROM coupon WHERE date("Y-m-d", "time") = $date' );
The error is:
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 ' "time") = $date' at line 1
While, i’m comparing a timestamp which is the field time, and a date which is $date
Thanks in advance..
timeshould not be quoted as it is a field reference, not a string literal.Note: You are susceptible to SQL Injection.