Reputation: 5029
I'm having a hard time finding an example of just making a simple update function to update the time in my timestamp column in any row that contains my $username
variable. Any ideas how I could make this work?
class updateUserData {
public function __construct() {
mysql_connect("mysql.mymysql.com", "admin", "password");
mysql_select_db("my_db");
}
function userUpdate($username) {
return mysql_query("UPDATE mytable WHERE username = '$username' SET timestamp = 'NOW()'");
}
}
Upvotes: 1
Views: 395
Reputation: 25604
"UPDATE mytable SET timestamp = NOW() WHERE username = '$username' "
skip '' around NOW() and provide correct order of UPDATE SET WHERE
Upvotes: 0
Reputation: 101614
Reverse the order of your update. See MySQL UPDATE Syntax
UPDATE mytable
SET timestamp = NOW()
WHERE username = 'username'
Also, NOW()
is a function, so don't enclose it in quotes.
Upvotes: 3