syntax error

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

syntax error

Post 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? :(
MeOnTheW3
Forum Commoner
Posts: 48
Joined: Wed Nov 13, 2002 3:28 pm
Location: Calgary, AB

Post 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
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

damnit, that's what i get for pullin an all nighter. :roll:

thanks a lot.
MeOnTheW3
Forum Commoner
Posts: 48
Joined: Wed Nov 13, 2002 3:28 pm
Location: Calgary, AB

Post by MeOnTheW3 »

Glad to be able to help
Post Reply