> Thanks to everyone for the suggestions. Got it fixed. Just added a couple > lines of code - > $sql1 = "select * from endusers where name like '$name'"; > $result1 = mysql_query($sql1); > $count1 = mysql_num_rows($result1); > if ($count1 == "0" ) > $sql = "insert into endusers......blah blah blah > Now it works fine, no more duplicate entries.
But now you're doing two queries for every insert. If you simply made your columns unique and let the database handle it, you'd only have to do one INSERT. Then check affected_rows() or mysql_error() to see if either no rows were affected (no rows inserted) or the error mentions duplicate. If either is the case, the row wasn't inserted because of a unique constraint. If there is an error but it's not "duplicate" or whatever, then it's another error and you should show it. ---John W. Holmes... Amazon Wishlist: http://www.amazon.com/o/registry/3BEXC84AB3A5E PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php