0

I want to update my database but its not working please help. Suppose i have current point (10 points) I want to Add 1 points, but it changes the current point (10 points) to 1. Not adding 10 to 1 = 11

$points = $user_home->runQuery("UPDATE tbl_users SET spoints = 'spoints' + 1 WHERE userID=:uid");
$points->execute(array(":uid"=>$_SESSION['userSession']));
jayash
  • 9
  • 5

3 Answers3

0

you must remove the quotes around the field name or use backticks like this:

SET spoints = `spoints` + 1

OR 

SET spoints = spoints + 1
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Bernd Buffen
  • 14,525
  • 2
  • 24
  • 39
0

Try with this: $points = $user_home->runQuery("UPDATE `tbl_users` SET spoints = spoints + 1 WHERE userID=:uid");

0

You're using ' instead of ` therefore it'd be:

$points = $user_home->runQuery("UPDATE `tbl_users` SET `spoints` = `spoints` + 1 WHERE `userID` = :uid");
$points->execute(array(":uid"=>$_SESSION['userSession']));
Option
  • 2,605
  • 2
  • 19
  • 29