mysql_query("LOCK TABLES `counter` WRITE;") or die(mysql_error());
$res = mysql_query("SELECT `unID` FROM `counter`;") or die(mysql_error());
$row = mysql_fetch_assoc($res);
$unID = $row['unID'] + 1;
mysql_query("UPDATE `counter` SET `unID`=`unID`+1;") or die(mysql_error());
mysql_query("UNLOCK TABLES;") or die(mysql_error());
This is 100% guarantee that $unID will be unique for every user who visit web ?
mysql table type: MyISAM
From the manual:
So the answer is yes, the number will be unique.