0

Hello,

I have this code:

            mysql_query("UPDATE users SET BasicLevel = BasicLevel +1 where username='Admin'");

but its not increasing the integer. The field names are correct as well as the username. Can anyone help me? And yes, I am connected to the database.

3
Contributors
7
Replies
8
Views
5 Years
Discussion Span
Last Post by moneeshot
0

Well, there's nothing wrong with the basic syntax that I can see. Try `backticking` your fieldnames and tablenames, but I can't see that it would make a difference in this case.

0

what is BasicLevel? is this set? is it a variable from the page? you may need a subquery in your SQL

"UPDATE users SET BasicLevel = (SELECT BasicLevel+1) where username='Admin'"
0

thats a bit odd, did you test the code to make sure it works? BasicLevel = 6. hardcode it just to be sure. you could select the value, let php do the math then insert the value. thats the long road.

0

ok, try this, it's a little more structured

UPDATE users a
INNER JOIN users b ON a.username = b.username
SET a.BasicLevel = b.BasicLevel+1 where a.username='Admin'

if that don't work I have no idea? definately double check you column to make sure the datatype is int.

Edited by moneeshot

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.