I have a question, how can I create a random string in PHP and check on a SQL if the string exist, if exist, create a new one, but if it doesnt exist use it
I have this code to create the random string:
$original_string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$random_string = get_random_string($original_string, 14);
echo $random_string;
And the MySQL I would like to check if the random string is already been use is this one:
CREATE TABLE `en_videos` (
`id` int(11) NOT NULL auto_increment,
`name` text,
`code` text,
`description` text,
`hits` int(11) default NULL,
`program` int(11) default NULL,
`lenght` int(11) default NULL,
`hd` int(11) NOT NULL default '1',
`subtitles` int(11) NOT NULL default '1',
`type` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
I would like to check if the random string exists on the code field