kaiman Posted October 26, 2009 Share Posted October 26, 2009 As the title states, I am trying to copy column1 to column2 and then update column1 and column3. This is for a login script where I want the lastlogin timestamp to be replaced by the currentlogin timestamp and then have the currentlogin timestamp and users currentip updated for my records. I am just looking for advice on the method/syntax before running this. Here is what I have so far: // get current ip address <?php $currentip = getenv('REMOTE_ADDR'); // update database by copying the timestamp from currentlogin to lastlogin and inserting the current ip address and current login timestamp $sql="UPDATE $tbl_name SET lastlogin = currentlogin, currentip = '$currentip', currentlogin = NOW() WHERE username='$username' AND password='$pass'"; mysql_query($sql) or trigger_error("A MySQL error has occurred!"); ?> Thanks! kaiman Quote Link to comment https://forums.phpfreaks.com/topic/179103-solved-copy-column1-to-column2-and-then-update-column1-and-column3-with-php-mysql/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 26, 2009 Share Posted October 26, 2009 ...before running this. All code must be tested at some point in time. One of the points of programming is that you can try something to see if it does what you expect. It's only when it does not work and you cannot figure out how to make it work that you run to a programming forum to ask for help. If you get stuck at the point of not even trying something in programming, it is going to take you a really long time to complete what you are working on. Quote Link to comment https://forums.phpfreaks.com/topic/179103-solved-copy-column1-to-column2-and-then-update-column1-and-column3-with-php-mysql/#findComment-944990 Share on other sites More sharing options...
kaiman Posted October 26, 2009 Author Share Posted October 26, 2009 * SOLVED * Okay, you raise a good point. I will test before posting next time. Thanks anyway... BTW I did run the code and it works as expected kaiman Quote Link to comment https://forums.phpfreaks.com/topic/179103-solved-copy-column1-to-column2-and-then-update-column1-and-column3-with-php-mysql/#findComment-945068 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.