Jump to content

Duplicate Record Enter In Db Table


amankaurm

Recommended Posts

hello

 

I am faceing one problem in my project.

 

Data entered by user here UserId is unique auto increment by code

 

************************

UserId Name Time

 

12LAB00019 Vijay 24Nov 2012 02:11:34PM

12LAB00019 Vijay 24Nov 2012 02:11:34PM

 

one user get same UserId in database table it store as

UID - This is auto increment

 

UID UserId Name Time

 

18 12LAB00019 Vijay 24Nov 2012 02:11:34PM

19 12LAB00019 Vijay 24Nov 2012 02:11:34PM

Double Record entered in Database

*****************************

 

This is another big problem that one user entered so many time

from 5234 to 5248 all ids are taken by this user

 

UserId Name Time

 

12LAB05234 Jay Kumar 30Nov 2012 5:00:25PM

12LAB05234 Jay Kumar 30Nov 2012 5:00:25PM

 

12LAB05237 Jay Kumar 30Nov 2012 5:00:26PM

12LAB05237 Jay Kumar 30Nov 2012 5:00:26PM

12LAB05237 Jay Kumar 30Nov 2012 5:00:26PM

 

12LAB05239 Jay Kumar 30Nov 2012 5:00:27PM

12LAB05239 Jay Kumar 30Nov 2012 5:00:27PM

 

12LAB05242 Jay Kumar 30Nov 2012 5:00:28PM

12LAB05242 Jay Kumar 30Nov 2012 5:00:28PM

12LAB05242 Jay Kumar 30Nov 2012 5:00:28PM

 

12LAB05244 Jay Kumar 30Nov 2012 5:00:29PM

12LAB05244 Jay Kumar 30Nov 2012 5:00:29PM

 

12LAB05246 Jay Kumar 30Nov 2012 5:00:32PM

12LAB05246 Jay Kumar 30Nov 2012 5:00:32PM

 

12LAB05248 Jay Kumar 30Nov 2012 5:00:33PM

12LAB05248 Jay Kumar 30Nov 2012 5:00:33PM

 

 

In Admin section this data is coming in such a way ...

 

please suggest me solution

Link to comment
Share on other sites

I don't understand what this is

 

"UID - This is auto increment

UID UserId Name Time"

 

 

Anyway, I usually run a query and if a certain value is already present in a column or in a column with a user id of xx I wont enter the data.

 

Also if you verify your data and your form wont process with out the info being filled out you maybe able to reset a value to false after the info is entered. Then it wont be entered again.

Edited by floridaflatlander
Link to comment
Share on other sites

actually problem comes here in this function coz earlier all conditions ar checked then data come here in this function to insert in database. here i enter data in 2 tables....

 

function addOnlineUser(......){

 

mysql_query('LOCK TABLES user');

mysql_query('LOCK TABLES usereducation');

 

 

Sql = "INSERT.......user....."

 

$uid = mysql_insert_id();

 

Sql = "INSERT.......usereducation...

.."

 

.........so and so.......

$UserId = $this->AutoUserId($PostApply,$uid);

 

mysql_query('UNLOCK TABLES');

 

//function END

 

 

user_id field is auto increment and primary key.....and

UserId field is made like(12LAB00025 .. 12 is Year , LAB is Post, 000025 is serial number).

 

see in my previous post

 

user_id UserId Name Time

 

18 12LAB00019 Vijay 24Nov 2012 02:11:34PM

19 12LAB00019 Vijay 24Nov 2012 02:11:34PM

 

Double Record entered in Database

 

here i generate UserId -

$uid = mysql_insert_id();

$UserId = $this->AutoUserId($PostApply,$uid);

Link to comment
Share on other sites

Here is PHP Code where data is inserted in database

 

function addOnlineUser($PostApply,$name,$fathername,$email,$dob,$Uniq_Id,$age_on_year,$age_on_month,$age_on_day,

$ImgVal, $subBoard, $subPassYear, $subHigherQ ,

$Exservice,$Ex_Served, $Ex_yr, $Ex_mon, $Ex_day, $Designation,

$PwdPc, $HHOH, $disability, $OrgCat,

$subDDVal, $subDDIPO_NO, $subDDIPO_Date, $subDDIPO_Amount,$subDDIPO_Branch,

$Lang,$Nation,$subNationOthers,

$subPermanentAddLine1, $subPermanentAddLine2,$subPermanentCity, $subPermanentState,$subPermanentPincode,

$subPresentAddLine1, $subPresentAddLine2,$subPresentCity, $subPresentState,$subPresentPincode,

$subCity, $subDistrict, $subState, $subCommunity ,

$subStation, $TodayDate

){

 

 

 

date_default_timezone_set('Asia/Calcutta');

$DateTime = date('l jS \of F Y h:i:s A');

 

mysql_query('LOCK TABLES user');

mysql_query('LOCK TABLES usereducation');

 

$UserId = $Uniq_Id;

$q = "INSERT INTO ".TBL_USER."(UserId,postapply,name,fathername,email,dob,uniq_Id,age_on_year,age_on_month,age_on_day,imgval,

exserviceman,ex_Served,ex_yr,ex_mon,ex_day,ex_Designation,pwdpc,hhoh,pwdpc_disability,org_cat,

dd_ipo,ddipo_NO,ddipo_Date,ddipo_Amount,ddipo_Branch, lang_id,nation_id,nationothers,

station,TodayDate

)

VALUES

('$UserId','$PostApply','$name', '$fathername', '$email','$dob','$Uniq_Id',$age_on_year,$age_on_month,$age_on_day,'$ImgVal',

$Exservice,'$Ex_Served',$Ex_yr,$Ex_mon,$Ex_day,'$Designation',$PwdPc,$HHOH,'$disability',$OrgCat,

'$subDDVal','$subDDIPO_NO','$subDDIPO_Date',$subDDIPO_Amount,'$subDDIPO_Branch',

$Lang,$Nation,'$subNationOthers',

'$subStation', '$TodayDate' )";

$result = mysql_query($q, $this->connection);

$uid = mysql_insert_id();

 

$p = "INSERT INTO ".TBL_USEREDUCATION."(user_uniqid, board, board_passyr, HigherQ ,

PermanentAddLine1, PermanentAddLine2, PermanentCity, PermanentState, PermanentPincode,

PresentAddLine1, PresentAddLine2, PresentCity, PresentState, PresentPincode,

Time, city, district, state, community

)

VALUES

('$Uniq_Id','$subBoard',$subPassYear, '$subHigherQ' ,

'$subPermanentAddLine1', '$subPermanentAddLine2','$subPermanentCity', '$subPermanentState',$subPermanentPincode,

'$subPresentAddLine1', '$subPresentAddLine2','$subPresentCity', '$subPresentState',$subPresentPincode,

'$DateTime', '$subCity', '$subDistrict', '$subState', '$subCommunity'

)";

 

$resultP = mysql_query($p, $this->connection);

 

$UserId = $this->AutoUserId($PostApply,$uid);

 

$up_id = "UPDATE ".TBL_USER." SET UserId = '$UserId' WHERE Uniq_Id = '$Uniq_Id'";

mysql_query($up_id, $this->connection);

 

/* Error occurred, return given name by default */

if(!$result){

$Delq = "DELETE FROM ".TBL_USEREDUCATION." WHERE user_uniqid = '$Uniq_Id'";

mysql_query($Delq, $this->connection);

}

if(!$resultP){

$DelP = "DELETE FROM ".TBL_USER." WHERE uniq_Id = '$Uniq_Id'";

mysql_query($DelP, $this->connection);

}

mysql_query('UNLOCK TABLES');

 

if(!$result || !$resultP){

 

return NULL;

}

 

 

return $result;

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.