Reputation: 4519
I'm trying to add a points row to to a table of current users on my website but I keep getting the error #1062 - Duplicate entry '10' for key 'PRIMARY'
when I try to set the default points to 10 for all users. I see this being a problem when both users end up reaching a same score of 150 etc. Here are the settings for my table
Here is my query
<?php
session_start();
$db = mysqli_connect("host", "username", "password", "db_name");
$username = $_SESSION['username'];
mysqli_query($db, 'UPDATE login_users SET Points=Points+1 WHERE username=$username');
?>
Any ideas to allow the same numbers to be stored in the points row? It seems that it is treating it as an "ID" instead of just a number. Thanks!
Upvotes: 0
Views: 79
Reputation: 211560
It looks like you have a UNIQUE
index on the Points
column, so you should probably drop it since that doesn't make any sense.
You might want paste the results of SHOW CREATE TABLE login_users
rather than a screenshot of the database editor you use.
Upvotes: 1