PHP_CHILD Posted January 27, 2013 Share Posted January 27, 2013 Help pls.. i just want to update a field called last_visited date in my table. Each time the user logins. so i tried using this way UPDATE table SET c = c + 1 WHERE a = 1; INSERT INTO table (a, b, c) VALUES (1, 2, 3) ON DUPLICATE KEY UPDATE c = c + 1; $dd="INSERT INTO file(lname,mid,last_date) VALUES ('$value1','$value2','$value3') ON DUPLICATE KEY UPDATE last_date_a=$value3; mysql_query($dd) or die(mysql_error()); $aa="UPDATE table SET date_a_in=1 WHERE lname='".$_SESSION['lname']."' AND password='".$_SESSION['password']."' AND mid='1'"; mysql_query($aa) or die(mysql_error()); date_a_in is the index i set as unique for last_date field.... Help pls i can't get this.. Thanks a lot in advances...... Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 27, 2013 Share Posted January 27, 2013 That can't be your actual code, as it would produce a parse error. Why are you trying to do an insert and an update? If all you want to do is update the date, do UPDATE users SET last_date = CURDATE() WHERE user_id = (put the user's id here). You don't need to do anything with the index, or any other fields. Use the user's unique ID, not any other information. Quote Link to comment Share on other sites More sharing options...
PHP_CHILD Posted January 28, 2013 Author Share Posted January 28, 2013 That can't be your actual code, as it would produce a parse error. Why are you trying to do an insert and an update? If all you want to do is update the date, do UPDATE users SET last_date = CURDATE() WHERE user_id = (put the user's id here). You don't need to do anything with the index, or any other fields. Use the user's unique ID, not any other information. thank u.............. it is working ....am makin things so complex ... 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.