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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.