0

I'm trying to use a variable in a Update to a field.
The variable will change the amount of the increment that occurs in that field.
I can't use a fixed amount, as it will change according to the user.

The Following won't work

$points = 5;
$query2 = "UPDATE `Cust` SET points = points + $points WHERE name = '$name'";
$result = mysql_query($query2);

What am I doing wrong with the above query?

Yet this one does work
$query2 = "UPDATE `Cust` SET points = points + 5 WHERE name = '$name'";
$result = mysql_query($query2);

Thank you
Ray Ward
ray@lauray.net

2
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by ray@lauray.net
0

Didn't tested it, but I think, you are missing quotes, try this:

$points = 5;
$query2 = "UPDATE `Cust` SET points = points + '$points' WHERE name = '$name'";
$result = mysql_query($query2);

Note: Now I have tested it, its working :)

Edited by desup: Testing

0

Didn't tested it, but I think, you are missing quotes, try this:

$points = 5;
$query2 = "UPDATE `Cust` SET points = points + '$points' WHERE name = '$name'";
$result = mysql_query($query2);

Note: Now I have tested it, its working :)

Thank You! It works great....
Ray

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.