I have a set called signup and a table called points. I'm trying to add to the table points, but for only a specific username. With the code I have it adds to points but to all users.
Code: Select all
$sql="UPDATE signup SET points = 'points + 30'";Moderator: General Moderators
Code: Select all
$sql="UPDATE signup SET points = 'points + 30'";Code: Select all
$sql="UPDATE signup SET points = points + 30 WHERE UID=$_SESSION[UID]";Here, it seems that either in the table signup there is no column named UID or $_SESSION[UID] has no value. Make sure that the both exists else the code should work.harisp wrote:this is the code that I put in:but it does not update the points set at all now.Code: Select all
$sql="UPDATE signup SET points = points + 30 WHERE UID=$_SESSION[UID]";
You really need to study how SQL works. To start off with, your table is named signup, not points, which is the name of the field. "Set" is merely a part of the SQL command. Next, by not using a WHERE clause, you are telling it to update every row in the table. If you are working with a real, live database, you are risking the content of all your data by trying to use SQL without understanding its syntax.harisp wrote:This may sound very easy, but it's bugging me that I can't figure it out. I'm pretty decent with C++, but kinda rough with php.
I have a set called signup and a table called points. I'm trying to add to the table points, but for only a specific username. With the code I have it adds to points but to all users.
What am I doing wrong and how can I get it to work right?Code: Select all
$sql="UPDATE signup SET points = 'points + 30'";