"John W. Holmes" <[EMAIL PROTECTED]> wrote on 06/04/2003 05:24:22 

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

Thanks for the tips, I'll work on that. In the meantime, this database is 
low useage, very specialized information for a small market segment, so 
for now
it will be okay. It'll never have hundreds or thousands of hits per day. 
But I 
will look into making the suggested changes.

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to