Q:

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 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.

A:

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.

