You could use intval($row['number']); to force it, but be careful that
you may hit upper bounds around 2 Billion as integers are always signed
in PHP (unfortunately), and mysql lets you store unsigned. It'll also
depend on your OS.
If you're checking the value only, you can use
is_numeric($row['number']) I think.
And also keep in mind that PHP will cast on the fly as needed...
If ($row['number'] == '123')
If ($row['number'] == 123)
Will both return true.
Also, could you change your name from "hjfg sdfdsf" to something more
sane -- unless that really is your name, then I feel sorry for you and
would advise you to go on "Wheel of Fortune", and buy a vowel...
"Some people, when confronted with a problem, think 'I know, I'll use
Now they have two problems.
> -----Original Message-----
> From: hjfg sdfdsf [mailto:[EMAIL PROTECTED]
> Sent: Monday, August 27, 2007 1:59 PM
> To: firstname.lastname@example.org
> Subject: [PHP-DB] Integer in DB becomes string in PHP?
> I have a table "test_table" with one column:
> number int(11)
> (also see phpmyadmin database dump at the end of this mail).
> it has two values, 123 and 150.
> i select and output one of those numbers using the following code:
> --- php code start ---
> $con=mysql_connect('127.0.0.1', 'root', '');
> mysql_select_db('testdb', $con);
> $result=mysql_query('select * from test_table where number=123');
> --- php code end ---
> that outputs:
> --- output start ---
>  => 123
> [number] => 123
> string(3) "123"
> --- output end ---
> 1) Is this normal?
> 2) Can this behaviour be changed / fixed?
> Wissenswertes für Bastler und Hobby Handwerker.BE A BETTER
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php