Jump to content

[SOLVED] copy column1 to column2 and then update column1 and column3 with php mysql


Recommended Posts

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

 

 

...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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.