RE: [PHP] Stopping Multiple Entries in mySQL DB
Hi, Ok i cant actully do this. I have many multiple entries already in the table which i do not wish to delete. And it won't alter table with these multiple entries. So what i need is a PHP Engineered solution, where my PHP code would check for existing entries and deny entry Thanks, T. Edison Jr. --- John Holmes [EMAIL PROTECTED] wrote: I just want my Adding Into Database script to check if the Name/Country already exists, and if it does, it shouldn't be allowed. If some with Name : Jackson Country : USA exists in my DB, no one with same name/country should be able to add his name/country in the DB. Have your database handle that, not PHP. When you create your table, make the combo of Name and Country unique. CREATE TABLE your_table { Name VARCHAR(15), Country VARCHAR(15), UNIQUE Name_Country (Name, Country) } Then you can have Jackson, USA, Jackson, UK, Someone Else, USA, etc...just not the same combination at all. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __ Do You Yahoo!? Yahoo! Health - Feel better, live better http://health.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Stopping Multiple Entries in mySQL DB
Ok i cant actully do this. I have many multiple entries already in the table which i do not wish to delete. And it won't alter table with these multiple entries. So what i need is a PHP Engineered solution, where my PHP code would check for existing entries and deny entry So do it... SELECT 1 FROM your_table WHERE name = 'NAME FROM FORM' AND city = 'CITY FROM FORM' If a row is returned, then a match is found and you shouldn't insert it again. If no row is returned, then there's no match and you can insert. You'd be better off to clean up your database now, though... ---John Holmes... --- John Holmes [EMAIL PROTECTED] wrote: I just want my Adding Into Database script to check if the Name/Country already exists, and if it does, it shouldn't be allowed. If some with Name : Jackson Country : USA exists in my DB, no one with same name/country should be able to add his name/country in the DB. Have your database handle that, not PHP. When you create your table, make the combo of Name and Country unique. CREATE TABLE your_table { Name VARCHAR(15), Country VARCHAR(15), UNIQUE Name_Country (Name, Country) } Then you can have Jackson, USA, Jackson, UK, Someone Else, USA, etc...just not the same combination at all. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __ Do You Yahoo!? Yahoo! Health - Feel better, live better http://health.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Stopping Multiple Entries in mySQL DB
Glory! I just want my Adding Into Database script to check if the Name/Country already exists, and if it does, it shouldn't be allowed. If some with Name : Jackson Country : USA exists in my DB, no one with same name/country should be able to add his name/country in the DB. Can anyone hint? T. Edison Jr. __ Do You Yahoo!? Yahoo! Health - Feel better, live better http://health.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Stopping Multiple Entries in mySQL DB
I just want my Adding Into Database script to check if the Name/Country already exists, and if it does, it shouldn't be allowed. If some with Name : Jackson Country : USA exists in my DB, no one with same name/country should be able to add his name/country in the DB. Have your database handle that, not PHP. When you create your table, make the combo of Name and Country unique. CREATE TABLE your_table { Name VARCHAR(15), Country VARCHAR(15), UNIQUE Name_Country (Name, Country) } Then you can have Jackson, USA, Jackson, UK, Someone Else, USA, etc...just not the same combination at all. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Stopping Multiple Entries in mySQL DB
do that plus with your insert, just do INSERT IGNORE . John Holmes [EMAIL PROTECTED] wrote in message 01c2358a$bd729fc0$b402a8c0@mango">news:01c2358a$bd729fc0$b402a8c0@mango... I just want my Adding Into Database script to check if the Name/Country already exists, and if it does, it shouldn't be allowed. If some with Name : Jackson Country : USA exists in my DB, no one with same name/country should be able to add his name/country in the DB. Have your database handle that, not PHP. When you create your table, make the combo of Name and Country unique. CREATE TABLE your_table { Name VARCHAR(15), Country VARCHAR(15), UNIQUE Name_Country (Name, Country) } Then you can have Jackson, USA, Jackson, UK, Someone Else, USA, etc...just not the same combination at all. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php