seany123 Posted November 22, 2011 Share Posted November 22, 2011 im running this kinda query in php mysql_query("UPDATE `user_log` SET `id`='$id' WHERE `user_id`='$user_id'"); $id is exactly the same as the id in the query ALL im wanting it to do is just trigger then UPDATE so the timestamp on the row updates, but it doesnt work. it DOES work if i change $id to something random, (which actually changes the values.) any ideas? i thought maybe i could update the timestamp value to the value of now() or something but i dont know if that would work. Quote Link to comment Share on other sites More sharing options...
teynon Posted November 22, 2011 Share Posted November 22, 2011 Can you paste your table stucture or create code? It should update the timestamp just be doing "UPDATE table WHERE ID = 'id'" You shouldn't have to change anything. Quote Link to comment Share on other sites More sharing options...
seany123 Posted November 22, 2011 Author Share Posted November 22, 2011 CREATE TABLE IF NOT EXISTS `user_log` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `show` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `season_id` int(11) NOT NULL, `episode_id` int(11) NOT NULL, `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=2 ; i have solved the problem by doing what i said and updating the date=now() but im still disappointed i had to do a "trick" to get this working. Quote Link to comment Share on other sites More sharing options...
teynon Posted November 22, 2011 Share Posted November 22, 2011 I guess i've never really had to do that without updating some data. But apparently you will have to do that, as MySQL detects changes. So if your run update row = row, no change has been made. You'll have to use the now() mysql function. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.