Hi, You can also create an UNIQUE INDEX on 'email' field. You can then directly insert, it will fail if a record with the same email already exist.
Hope this helps -- Joseph Bueno NetClub/Trader.com Cary wrote : > > You might try something like this.(unless I am missing something:-) > > $result = mysql_query ("select * from email2 where email = $email"); > if (mysql_num_rows($result)) > { <record already exists>} > else > {<insert a new record>} > > Cary > > At 07:28 AM 1/28/02, [EMAIL PROTECTED] wrote: > >I have a table like this : > > > >+-------+----------+------+-----+---------+----------------+ > > > >| Field | Type | Null | Key | Default | Extra | > > > >+-------+----------+------+-----+---------+----------------+ > > > >| id | int(11) | | PRI | 0 | auto_increment | > > > >| isim | char(26) | YES | | NULL | | > > > >| email | char(30) | YES | | NULL | | > > > >+-------+----------+------+-----+---------+----------------+ > > > > > > > >I take email address from web with php.. > > > >I want to control inserting email address.. > > > >I want to insert the same address only one time. > > > >my code: > > > >................... > > > >mysql_connect(.............) or die("veritabanina baglanilamadi"); > > > >mysql_select_db("db_edakom"); > > > >$result = mysql_query ("select * from email2"); > > > > > > > >if ($email == mysql_fetch_array ($result)) { > > > > echo "Bu email adresi daha once girilmistir."; > > > > echo 'tekrar denemek icin <a href="javascript:history.go(-1) > > >tiklayiniz.</a>'; > > > >} > > > > > > > >else { > > > >$query = "insert into email2 values('', '$isim','$email')"; > > > >mysql_query($query) or die("Cant insert data!"); > > > >print "Islem tamamlandi"; > > > >mysql_close(); > > > > } > > > > > > > >HOW CAN I DO THIS? > > > > > > > >Edakom Internet Sorumlusu > > > > Gokce Akkaya > --------------------------------------------------------------------- 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