Value 10 gets reset to 1
I have this problem, I store a number in a database field. After a while I check if a value exist and if it does I take the number and add 1 this works fine up until 10, when I add a number to 10 it gets reset to 2 as if the zero is not counted开发者_如何学C for.
$row = pg_fetch_array($result,0);
$count = (int)$row[1]['count'];
$count++;
Table
Column | Type | Modifiers
----------+--------------------------+----------------------------------------------------
count | character varying(255) |
I also tried to change it to integer the column and also no luck.
You're indexing the row twice. Use either $row[1]
or $row['count']
, not both. When you use both, the second index operation will index the string, giving you the first character. This will cause problems when you hit double digits.
you need either row[1] or row['count'], but not them both
精彩评论