Hi, Yes the user is logged in. The system knows who is tipping by their nickname and unique id system. So if I put the update query in the else statement would this be the easy fix? I use something like a field called tipped in the table, so if they have tipped it goes to y and if never tipped it's blank. I think it should show that in the query. Cant remember, I did the scripts 2 or 3 years ago. Just want to tidy it up. J Chris <dmagick@xxxxxxxxx> wrote: JeRRy wrote: > Hi, > > I'll admit it, this is damned messy. But I want to learn from the list in how to sort it out. Than for future refrence I will know... > > Now I am running 2 different queries/statements here completely seperate. I have made the "nickname" field in the database UNIQUE. So than when I have this sort of query setup no matter what their will only be one "nickname" entry for that user. So when people update their profile a new "nickname" is not inserted but it is updated. But I want it all in one PHP call. How do I do this? How are you differentiating between the statements? eg they are logged in, or you check with a database query or .... ? You could do something like this: // check for $_GET['tipid'] - if it's there, we're updating our tips. // if it's not, then we're adding new tips. if (isset($_GET['tipid'])) { $query = "UPDATE " ...... $success_message = "Your tips have been updated"; } else { $query = "INSERT INTO " ..... $success_message = "Your tips have been saved"; } $result = mysql_query($query); if ($result) { echo $success_message; } else { echo "Problem!! "; } -- Postgresql & php tutorials http://www.designmagick.com/