Jump to content

help with insert update php mysql php beginner


PHP_CHILD

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

Archived

This topic is now archived and is closed to further replies.

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