Jump to content

Help with variables in mysql query!


akshay1234

Recommended Posts

i'm trying to send across a very simple query to mysql through php, but cannot get the variables to work. the php error i receive is "Parse error: syntax error, unexpected T_VARIABLE in C:\Program Files\XAMPP\xampp\htdocs\oauth\login\checklogin.php on line 20"

 

i'm trying to update a field named "last_accessed" in the table. i have the connection down, and the database is all set.

 

   
// time to update timestamp of LAST ACCESSED
    $timestamp = date("l F d, Y, h:i A");
    mysql_query("UPDATE members SET last_accessed = "$timestamp" WHERE myusername = "$mygivenusername" AND mypassword = "$mygivenpassword"");

 

 

earlier on in the code, $mygivenusername and $mygivenpassword are defined through a POST form. that works ok.

btw the mysql_query line is line #20.

 

thanks (:

Link to comment
https://forums.phpfreaks.com/topic/233390-help-with-variables-in-mysql-query/
Share on other sites

Within a string, you can't use the same type of quotes that enclose a string without escaping them. Either change the inner double quotes to single quotes, or escape them with backslashes.

 

Also, why would you not just use a DATETIME field in the table, and use MySQL's NOW() function to insert the timestamp? Using the format you're using makes it rather difficult to do any comparisons or calculations with the timestamps.

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.