Jump to content

Lots of duplicate rows with an UPDATE?


joecooper

Recommended Posts

My site seems to be going well, but on the back end, the users database is going crazy with duplicate entrys. but its not doing it from an INSERT. it seems to be doing it with this code:

               $bitquery = $bitcoin->move("bittleship$username", "bittleships", $cost, $minconfirmations);
               if ($bitquery == true){
               $query = mysql_query("INSERT INTO `transactions` ( `id` , `username` , `type` , `amount`, `address`) VALUES ('', '$username', 'buyclicks', '$cost', '')")  or die(mysql_error());
               $query = mysql_query("UPDATE users SET `clicks` = `clicks`+$quantity, `balance`=`balance`-$cost WHERE `username` = '$username' ") or die(mysql_error());
               include('update.php');

 

Link to comment
Share on other sites

  id  username  email  password  balance  clicks  depositaddress 

      33 Bit*****al    -2.25 6 

      34 C**y    0 0 

      35 w*****f    -1.125 37 

      36 p***tc    -1.2 0 

      37 w*****f      -1.125 37 

      38 p***tc      -0.6 0 

      39 w*****f      -1.125 37 

      40 Bit*****al      -1.125 6 

      41 Bit*****al      0 6 

      42 w*****f    0 37 

      43 Bit*****al      0 6 

 

 

Its like its a copy of the user entry at the time they buy the clicks, users have reported things working fine

Link to comment
Share on other sites

The rows are being inserted by an INSERT query at some point in your code. Are you sure they are actually duplicates? Do you have a primary key or a unique index set to enforce uniqueness in your table and are you validating the data to insure duplicate rows are not being INSERTED?

 

What does a sample of the duplicate data look like? What's your code leading up to and including the INSERT query that is creating the rows in the first place?

 

Edit: And the sample output you just posted doesn't closely match either of the set of columns in the two queries you posted. What code or query produced that sample output you just posted? Are you sure that isn't data from the `transactions`table?

Link to comment
Share on other sites

The duplicates contain just the username, and balance of their account. the balance is coming from a JSON query from an account balance system. the password, email and deposit address remains blank.

 

This suggests it must be happening during an account balance update that happens. But no code is executed that Inserts. only updates.

 

the only insert is during account registration that checks for duplicate usernames, ensures all fields are filled out etc. I will have a reveiw of my code again.

 

Thanks!

Link to comment
Share on other sites

Ah found it!

 

$query = mysql_query("INSERT INTO `users` ( `id` , `username` , `email` , `password`, `depositaddress`, `balance`, `clicks`) VALUES ('', '" . mysql_real_escape_string($username) . "', '" . mysql_real_escape_string($email) . "', '" . mysql_real_escape_string($password) . "', '$depositaddress', '0', '0')")  or die(mysql_error());

 

^^ was in with the code that runs when boats are hit :D

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.