Reputation: 753
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?
Upvotes: 0
Views: 226
Reputation: 191819
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
Upvotes: 4