Log in

View Full Version : how can I empty my records



vividona
11-04-2008, 06:02 AM
Hiiii,

still checking my funny script

Now I have another problem

see here


CREATE TABLE `userregdata` (
`uid` mediumint(5) unsigned NOT NULL auto_increment,
`ufname` varchar(30) NOT NULL,
`ufamname` varchar(30) NOT NULL,
`username` varchar(30) NOT NULL,
`upswd` varchar(15) NOT NULL,
`uemail` varchar(40) NOT NULL,
`unumlev` int(3) NOT NULL default '1',
`uipadd` varchar(16) NOT NULL,
`uregdate` timestamp NOT NULL default CURRENT_TIMESTAMP,
PRIMARY KEY (`uid`),
UNIQUE KEY `username` (`username`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


as row (uid) is an auto-increment, the administrator should have row uid = 1

this is ok my script till now works fine

but the thing which is not fine, if I drop the database and need to install my script again
and when administrator register during installation process sometimes I found my script gave him uid number 3 , 4, 5 or 6 . . . etc instade of 1

how can I direct my script to uid = 1
how can I empty my record before the process of adminstrator registration


if( ! parent::getmail() == 0){
$QUERY = sprintf("INSERT INTO %s (`ufname`, `ufamname`,`username`, `upswd`,
`uemail`, `uipadd`, `uregdate`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', NOW())",
parent::BHL_DB_USER_TBL, parent::ClnUserFname(), parent::ClnUserFamName(), parent::ClnUserName(), parent::ClnUserPswd(),
parent::ClnUserEmAdd(), parent::CheckIpAdd(), parent::CurDate())or die(mysql_error());
$Result = mysql_query($QUERY);
}

james438
11-04-2008, 06:31 AM
I cheat. When I use auto increment I would occasionally delete a file and there would be a gap in the ID# sequence or I would delete all of the records and want to start over from ID of one and move up sequentially from there or where ever the deleted file occurred. I created the following a while back

$ID2=0;
$get_list1 = "select ID from table";
$get_list_res1 = mysql_query($get_list1) or die(mysql_error());
while ($recs1 = mysql_fetch_array($get_list_res1)) {
$IDa = $recs1['ID'];
if (($IDa-$ID)>1) {$ID++;$ID2=4;break;}
$ID=$IDa;
} if ($ID2<=1) $ID++;
echo $ID;

It scans the table and determines the appropriate ID# to use next by first looking for gaps in the ID# of the table and then displaying the next ID# if there are no gaps.

vividona
11-04-2008, 06:34 AM
hiiiii,

sometimes refuse to give uid = 1 if I drop my databse of no

I discover this now

I installed it new server

I found out uid = 6