Don't have time to totally disect it, but you might change the "if($num_rows)" to "if($num_rows > 0)" just to make sure.
Also, try echoing out your SQL statement to check and make sure things like $table got a real value or other silly things. Lastly, I usually use single quotes for SQL statements.. in this case, it would simplify your PHP SQL statement by removing the necessity to escape all the double quotes \" If you echo the SQL and it looks ok, try running it manually through mysql's command line or via a program like WinSQL Lite on Windows to try to isolate if it's the query or your PHP. Good luck! -TG = = = Original message = = = I am trying to write a script to handle event registration. Most of the people that will be registering are already in the database, but not all, and those that are may not have current information. Here is my latest effort, or at least a snippet of it... Can anyone point out where I went stupid, or if there is a better way of doing this? THANKS!!! <<<===--- BEGIN SNIPPET ---===>>> $db = @mysql_select_db($dbname, $connection) or die("Couldn't Select Database."); $link = mysql_connect("$server", "$user", "$pass"); mysql_select_db("$dbname", $link); $result = mysql_query("SELECT * FROM $table WHERE first_name='$first_name' AND hs_last_name='$hs_last_name' AND last_name='$last_name'", $link); $num_rows = mysql_num_rows($result); if($num_rows) $sql = "UPDATE $table SET first_name=\"$first_name\", last_name=\"$last_name\", hs_last_name=\"$hs_last_name\", guest_name=\"$guest_name\", street_address1=\"$street_address1\", street_address2=\"$street_address2\", city=\"$city\", state=\"$state\", zip=\"$zip\", phone1=\"$phone1\", phone2=\"$phone2\", email_address=\"$email_address\", number_attending=\"$number_attending\", payment=\"$payment\", registration_comments=\"$registration_comments\", date_registered=\"$today\" WHERE first_name=\"$first_name\" AND last_name=\"&last_name\""; $result = @mysql_query($sql,$connection) or die("Couldn't Execute Query."); else $sql = "INSERT INTO $table (first_name, last_name, hs_last_name, guest_name, street_address1, street_address2, city, state, zip, phone1, phone2, email_address, number_attending, payment, registration_comments, date_registered) VALUES (\"$first_name\", \"$last_name\", \"$hs_last_name\", \"$guest_name\", \"$street_address1\", \"$street_address2\", \"$city\", \"$state\", \"$zip\", \"$phone1\", \"$phone2\", \"$email_address\", \"$number_attending\", \"$payment\", \"$registration_comments\", \"$today\") "; $result = @mysql_query($sql,$connection) or die("Couldn't Execute Query."); <<<===--- END SNIPPET ---===>>> ___________________________________________________________ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php