0

I am wanting to move data from one column to another in a MySQL table.

Here is my code:

   $sDate = date("d-m-Y H:i:s");

mysql_query( "   UPDATE users
SET 
  logintimelast = logintime 

AND 
  logintime = '$sDate'");

However this does not update either column?

1
  • Seems you missed the WHERE clause Commented Dec 11, 2013 at 21:39

1 Answer 1

4

Because your syntax is wrong. lotintime AND logintime = '$sDate' is a boolean expression.

SET
    logintimelast = logintime,
    logintime = '$sDate'

Your query is vulnerable to injection. You should stop using ext/mysql and use properly parameterized queries with PDO or mysqli

Sign up to request clarification or add additional context in comments.

1 Comment

And you (OP) should add error reporting, which would've told you about the invalid SQL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.