Jump to content

Recommended Posts

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

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.

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

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.