唯一生成的密钥,仅用于与先前条目的数据库记录匹配[重复]

I have a list of keys I must use in this landing page... each extraced once from the array than inserted into the db for cheking of use/not used.

The keys are inserted into the db name "UNIQUE" table "IDS" row UNIQUE_ID

Code

 CREATE TABLE IDS (
UNIQUE_ID varchar(6) NOT NULL unique,
IDS int UNSIGNED NOT NULL default '0',
);


$con = mysqli_connect("127.0.0.1", "admin", "test");
mysqli_select_db($con, "unique");


function createID(){

//make random key from the list
$unique_id = Array(111111,111112,111113,111114,111115,111116...);
$id = $unique_id[array_rand($unique_id)];

//check to make sure this key isnt already in use
$con1 = mysqli_connect("127.0.0.1", "admin", "test");   
$resCheck = mysqli_query($con1,"SELECT count(*) FROM ids WHERE unique_id='{$u_id}' LIMIT 1");

$arrCheck = mysqli_fetch_assoc($resCheck);
if($resCheck['count(*)']){
    //key already in use
    return createID();
}else{
    //key is OK
    return $id;
}
}

 //get unique key
 $id = createID();

 //insert record into the db
 mysqli_query($con, "INSERT INTO IDS (UNIQUE_ID) VALUES ('{$id}')");

the keys are being generated and inserted into the database record

Issues:

The check against the db for key validity fails... same key is shown sometimes.

and also getting the following error:

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given

</div>