Reputation: 391
I'm working on a small project: a small number crunching game.
I want to have a php file that can accept inputs and interpret them into specified database updates.
Here is what I have so far. It doesn't seem to be working for me.
$name = $_GET['n'];
$action = $_GET['a'];
$result = mysql_query("SELECT * FROM players WHERE Username ='".$name."'");
while($row = mysql_fetch_array($result)) {
if ($action = "rankup") mysql_query("UPDATE players SET Level 'Level+1' WHERE Username='".$name."'");
}
mysql_close($con);
I'm not getting any errors, but its not working, and all the database connections are fine.
I dont know what the problem is.
Upvotes: 1
Views: 217
Reputation: 808
You want to enter your sql query like this
'UPDATE players SET Level= (Level+1) WHERE Username='.$name.'
Also any database function that begins with mysql should be replaced with mysqli. This is because PHP is phasing out functions beginning with mysql in the next edition.
Upvotes: 1
Reputation: 1215
Several mistakes here :
mysql_query
. The query with SET Level 'Level+1'
is invalid, you forgot a =
and remove quotes$action == 'rankup'
, not =
mysql_
functions.Upvotes: 2