Slight problem with mysql, php, and timestamps

ember

New Member
Messages
2
Reaction score
0
Points
0
Solved: Slight problem with mysql, php, and timestamps

Hello.

While trying to add a logging feature to record the current and previous pages of a logged in user, I came across a problem. Every time the page loads while logged in, the query causes an 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 '.10 8.42 pm' at line 1
I have tried everything I could think of at this point, and was unable to find a problem with the timestamps when I googled it. Any help would be appreciated. The code that triggers this is below:
PHP:
$logquery = "INSERT INTO user_log (username, page, ip) VALUES ('$username', purchase.php, " . date('m.d.y g.i a') . "";
mysql_query($logquery) or die(mysql_error());
Thank you,
Nicolai Guarino(ember).
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
PHP:
$the_date = date('m.d.y g.i a') ;

$logquery = "INSERT INTO user_log (username, page, ip) 
             VALUES ('$username', 'purchase.php' , '$the_date' ) " ;

You are missing some quotes...
 
Top