Page 1 of 1

syntax error

Posted: Thu Nov 14, 2002 5:13 pm
by m3mn0n

Code: Select all

mysql_query("INSERT into $playerdb slpoints=slpoints+1 WHERE num='$numb';");
				mysql_query("UPDATE $playerdb SET slref='1' WHERE num = '$userїnum]';");
whats wrong with these? :(

Posted: Thu Nov 14, 2002 6:19 pm
by MeOnTheW3
mysql_query("INSERT into $playerdb slpoints=slpoints+1 ...

mysql does not know how to create the value slpoints in the slpoints+1.
Now if slpoints in slpoints+1 is a php variable then you need to have slpoints=$slpoints+1
Else if slpoints in slpoints+1 is meant to be 1 greater than the current highest value in the $playerdb.slpoints column then you only need to define it as an auto_increment column in the table structure, or you could do a prior SELECT MAX(slpoints) and save it in a var and use that.

You also don't need the trailing ';' inside the sql statements.

mysql_query("UPDATE $playerdb SET slref='1' WHERE num='$user[num]';");

first, if either column, slref or num, are defined as numeric columns, remove the single quotes.
Second, if num in $user[num] is a key, do it as $user['num']. but if it is a variable that is a reference to a key do it as $user[$num].

Hope that helps, let me know

Posted: Thu Nov 14, 2002 6:26 pm
by m3mn0n
damnit, that's what i get for pullin an all nighter. :roll:

thanks a lot.

Posted: Thu Nov 14, 2002 6:30 pm
by MeOnTheW3
Glad to be able to help