almightyegg Posted August 5, 2007 Share Posted August 5, 2007 $ip = $_SERVER["REMOTE_ADDR"]; $time = date("d-m-Y H:i:s"); $memberid = $mem[id]; $update = mysql_query("UPDATE users SET lastlogin = '$time' and ip = '$ip' WHERE id = '$memberid'") or die(mysql_error()); The problem is that it doesn't update lastlogin (and perhaps IP - I'm still on the same one as before) correctly. It updates as 1 every time, so it just puts 1 into the database ;( it's really bugging me because I can't think why?? Link to comment https://forums.phpfreaks.com/topic/63437-solved-aner-update-problem/ Share on other sites More sharing options...
Barand Posted August 5, 2007 Share Posted August 5, 2007 if lastlogin is a DATETIME field, use 'Y-m-d H:i:s'. In fact, even it is varchar use that format anyway. d-m-Y is useless as a db date. You could just ... SET lastlogin = NOW() Link to comment https://forums.phpfreaks.com/topic/63437-solved-aner-update-problem/#findComment-316180 Share on other sites More sharing options...
almightyegg Posted August 5, 2007 Author Share Posted August 5, 2007 I changed the format, yet it is still inputting it as 1 ??? Link to comment https://forums.phpfreaks.com/topic/63437-solved-aner-update-problem/#findComment-316216 Share on other sites More sharing options...
Barand Posted August 5, 2007 Share Posted August 5, 2007 What column type is lastlogin? Link to comment https://forums.phpfreaks.com/topic/63437-solved-aner-update-problem/#findComment-316217 Share on other sites More sharing options...
Barand Posted August 5, 2007 Share Posted August 5, 2007 Aha! $update = mysql_query("UPDATE users SET lastlogin = '$time' and ip = '$ip' WHERE id = '$memberid'") or die(mysql_error()); Change the "and" to a comma, it's treating the whols expression as a boolean: lastlogin = ($time && ip=$ip) .... SET lastlogin = '$time' , ip = '$ip' .... Link to comment https://forums.phpfreaks.com/topic/63437-solved-aner-update-problem/#findComment-316219 Share on other sites More sharing options...
almightyegg Posted August 5, 2007 Author Share Posted August 5, 2007 Ah great thanks Link to comment https://forums.phpfreaks.com/topic/63437-solved-aner-update-problem/#findComment-316220 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.