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')

And

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

ÐÆ5ÏÐ 

"Some people, when confronted with a problem, think 'I know, I'll use
XML.'"
Now they have two problems. 

> -----Original Message-----
> From: hjfg sdfdsf [mailto:[EMAIL PROTECTED] 
> Sent: Monday, August 27, 2007 1:59 PM
> To: php-db@lists.php.net
> Subject: [PHP-DB] Integer in DB becomes string in PHP?
> 
> hello,
> 
> 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 ---
> <?
> error_reporting(E_ALL);
> 
> $con=mysql_connect('127.0.0.1', 'root', '');
> mysql_select_db('testdb', $con);
> $result=mysql_query('select * from test_table where number=123');
> $row=mysql_fetch_array($result);
> 
> 
> print_r($row);
> 
> var_dump($row['number']);
> ?>
> --- php code end ---
> 
> that outputs:
> --- output start ---
> 
> Array
> (
>     [0] => 123
>     [number] => 123
>  )
> string(3) "123"
> --- output end ---
> 
> 
> 
> 1) Is this normal?
> 2) Can this behaviour be changed / fixed?
> 
> Thanks!
> 
> 
> 
> 
> 
>        
> ---------------------------------
>  Wissenswertes für Bastler und Hobby Handwerker.BE A BETTER 
> HEIMWERKER!
> 

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to