Sign in to follow this  
Followers 0
IndianaGuy

Update field to +1

3 posts in this topic

I am trying to make an INT field in my database to be updated from current value to current value +1. I have this so far but the value is not updating. Thank you

	$sql2 = "UPDATE tbl_team SET TM_Counter = TM_Counter + 1 WHERE TM_code=$access_code";
	$result2=mysqli_query($sql2);
	

Share this post


Link to post
Share on other sites

The WHERE clause probably doesn't match any rows.  Or maybe there's a database error that you're not checking for, I can't tell with just those 2 lines.  You should use prepared statements for that though, mysqli supports them and you should use a prepared statement any time you need to put any data in a query.

Share this post


Link to post
Share on other sites

My guess is that either TM_code is supposed to be a string or $access_code has an unexpected value.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0