List:MySQL and PHP« Previous MessageNext Message »
From:Skip Evans Date:February 12 2007 4:50pm
Subject:Interger values adding too much
View as plain text  
Hey all,

I have the following code block:

// get the number of points for this action
$sql="SELECT points FROM bsp_story_points WHERE 

echo "<br/>points to add:$pts";

// update the user's record with the new ponts.
$sql="UPDATE users SET points = (points + $pts) 
WHERE id=$uid";
echo "<br>SQL:$sql";

echo "<br/>points added";

And here is the output from the echo statements:

points to add:50
SQL:UPDATE users SET points = (points + 50) WHERE 
points added

Now, I checked the value right before the UPDATE 
call, and it was 700. I am absolutely certain of 
this, but the value in the points column for the 
table users after the UPDATE runs is 800, not 750 
as it should be.

I've been running tests on this for two days and 
am completely baffled! I have tried this an 
embarrassing number of times, and it always adds 
either 100 or 150 points instead of the 50 points 
I think it should.

Any help on this would reward you with psychic 
pizzas with everything beamed your way.

I'm desperate for a solution to this as it is 
supposed to go into production today.

Thanks tons!

Skip Evans
Big Sky Penguin, LLC
61 W Broadway
Butte, Montana 59701
Check out PHPenguin, a lightweight and
versatile PHP/MySQL development framework.
Interger values adding too muchSkip Evans12 Feb