I’m trying to add a field in the user table for reputation. I use a + 1 increment through a form and for some reason it’s not updating.
Query I’m running.
$link = mysqli_connect("$server", "$user", "$pass", "$webdb") or die( "Error:" . mysqli_connect_error());
$username = mysqli_real_escape_string($link, (string) $_POST['user']);
$query= "Update `user` set `reputation` = 'reputation + 1' where `nicename`='$username'";
mysqli_query($link, $query) or die ("Error:" . mysqli_errno($link));
I have ran the query both inside of HeidiSQL and also through the button on my webpage and it doesn’t update which tells me whatever issue I’m facing is an issue in my query itself. Does anyone see the issue to where it would not work? I am trying to update the reputation panel to upgrade by one each time it is clicked; Thanks.
Remove the quotes. What you’re doing is like saying in PHP:
Side-note: It is redundant an inefficient to wrap a variable in quotes for no reason. Remove all the quotes from your
mysqli_connectcall.