joecooper Posted September 9, 2011 Share Posted September 9, 2011 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'); Quote Link to comment https://forums.phpfreaks.com/topic/246753-lots-of-duplicate-rows-with-an-update/ Share on other sites More sharing options...
joecooper Posted September 9, 2011 Author Share Posted September 9, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/246753-lots-of-duplicate-rows-with-an-update/#findComment-1267213 Share on other sites More sharing options...
PFMaBiSmAd Posted September 9, 2011 Share Posted September 9, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/246753-lots-of-duplicate-rows-with-an-update/#findComment-1267217 Share on other sites More sharing options...
joecooper Posted September 9, 2011 Author Share Posted September 9, 2011 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! Quote Link to comment https://forums.phpfreaks.com/topic/246753-lots-of-duplicate-rows-with-an-update/#findComment-1267526 Share on other sites More sharing options...
WebStyles Posted September 10, 2011 Share Posted September 10, 2011 Just an idea, since you cannot find any code with INSERT's: ... maybe you have a trigger set on another table that's inserting stuff into your users table? Quote Link to comment https://forums.phpfreaks.com/topic/246753-lots-of-duplicate-rows-with-an-update/#findComment-1267530 Share on other sites More sharing options...
joecooper Posted September 10, 2011 Author Share Posted September 10, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/246753-lots-of-duplicate-rows-with-an-update/#findComment-1267533 Share on other sites More sharing options...
PFMaBiSmAd Posted September 10, 2011 Share Posted September 10, 2011 Does that mean that was a unneeded query, that you removed it, and that this thread is solved? Quote Link to comment https://forums.phpfreaks.com/topic/246753-lots-of-duplicate-rows-with-an-update/#findComment-1267534 Share on other sites More sharing options...
joecooper Posted September 10, 2011 Author Share Posted September 10, 2011 indeed Quote Link to comment https://forums.phpfreaks.com/topic/246753-lots-of-duplicate-rows-with-an-update/#findComment-1267661 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.