woody79 Posted May 3, 2007 Share Posted May 3, 2007 i have a table with the primary key as id and i want the php script to insert values into the table but with a random 6 digit number. the problem i have is that if php randomly selects a number that is already in the table the values won't be entered. if youre wondering it is a confidentiality thing otherwise i would just use auto_increment Link to comment https://forums.phpfreaks.com/topic/49803-php-mysql-id/ Share on other sites More sharing options...
jitesh Posted May 3, 2007 Share Posted May 3, 2007 INSERT IGNORE INTO `....` ( ... ..... ..... ) VALUES ( .. .. . .. ....) Link to comment https://forums.phpfreaks.com/topic/49803-php-mysql-id/#findComment-244282 Share on other sites More sharing options...
trq Posted May 3, 2007 Share Posted May 3, 2007 the problem i have is that if php randomly selects a number that is already in the table the values won't be entered. So, check to make sure the value doesn't allready exist before running the insert query. If it does exist, create another id. Link to comment https://forums.phpfreaks.com/topic/49803-php-mysql-id/#findComment-244283 Share on other sites More sharing options...
woody79 Posted May 3, 2007 Author Share Posted May 3, 2007 INSERT IGNORE INTO `....` ( ... ..... ..... ) VALUES ( .. .. . .. ....) ??? that went stright over my head So, check to make sure the value doesn't allready exist before running the insert query. If it does exist, create another id. Thanx but how would i do that Link to comment https://forums.phpfreaks.com/topic/49803-php-mysql-id/#findComment-244300 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.