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?? Quote Link to comment 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() Quote Link to comment 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 ??? Quote Link to comment Share on other sites More sharing options...
Barand Posted August 5, 2007 Share Posted August 5, 2007 What column type is lastlogin? Quote Link to comment 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' .... Quote Link to comment Share on other sites More sharing options...
almightyegg Posted August 5, 2007 Author Share Posted August 5, 2007 Ah great thanks 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.