That makes sense, sound like I'm redoing in PHP what the UNIQUE column
already does.
So all I need to do is modify my PHP trap using mysql_affected_rows() =
0, retun a error messagu to the used indicating a rcord already exists.
Will try it, THX!
Pete

Paul DuBois wrote:
> 
> At 5:46 PM -0500 6/27/01, Pete Kuczynski wrote:
> >Thanks Paul!
> >ps works great!
> >I modified the database with a UNIQUE column like you recommended
> >earlier, this will now help in the PHP script to trap the duplicate
> >entry and advise the user of the dup.
> 
> But if hostname now has a UNIQUE index on it, it won't even be possible
> for your table to have duplicate hostname values, other than NULL.
> 
> Probably all you need to do is just go ahead and try to insert the record,
> and if mysql_affected_rows() is 0, it was a duplicate and was rejected.
> 
> >
> ><?
> >     // check for duplicate row
> >     $query = "SELECT hostname, COUNT(*) AS count FROM asset
> >               GROUP BY hostname HAVING count > 1
> >     $result = mysql_query($query);
> >             // check if row is returned, if yes error, if no insert
> >             if (mysql_num_rows($result) != 0) {
> >                     echo "error";
> >             } else {
> >                     // DO INSERT
> >             }
> >     ?>
> >
> >Pete
> 
> --
> Paul DuBois, [EMAIL PROTECTED]

-- 
_______________________________________
Pete Kuczynski
Principal Field Engineer
DHL Airways Inc.
Infrastructure Technology & Services
(773)-462-9758
24/7 Helpdesk 1-800-434-5767
---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to