From:             harmen_php_net at xtremesf dot nl
Operating system: 
PHP version:      5.2.0
PHP Bug Type:     MySQLi related
Bug description:  Integers selected from a MySQL-database are treated as strings

Description:
------------
When executing the query below, I get the wrong result. Although the
database returns a integer, PHP treats it as a string. 

Here the relevant part of phpinfo():

MysqlI Support  enabled
Client API library version      5.0.27
Client API header version       5.0.27
MYSQLI_SOCKET   /tmp/mysql.sock

The version of the MySQL server is 5.0.27

Reproduce code:
---------------
<pre>
<?php
$rDB = mysqli_connect('localhost', 'user', 'password', 'db');
mysqli_select_db($rDB, 'db');

$rResult = mysqli_query($rDB, 'SELECT id FROM producten WHERE id =
4472');

var_dump(mysqli_fetch_array($rResult));

echo "\n---\n";

var_dump(mysqli_fetch_field($rResult));

?>
</pre>

Expected result:
----------------
array(2) {
  [0]=>
  int(4) "4472"
  ["id"]=>
  int(4) "4472"
}

---
object(stdClass)#3 (11) {
  ["name"]=>
  string(2) "id"
  ["orgname"]=>
  string(2) "id"
  ["table"]=>
  string(9) "producten"
  ["orgtable"]=>
  string(9) "producten"
  ["def"]=>
  string(0) ""
  ["max_length"]=>
  int(4)
  ["length"]=>
  int(11)
  ["charsetnr"]=>
  int(63)
  ["flags"]=>
  int(49699)
  ["type"]=>
  int(3)
  ["decimals"]=>
  int(0)
}

Actual result:
--------------
array(2) {
  [0]=>
  string(4) "4472"
  ["id"]=>
  string(4) "4472"
}

---
object(stdClass)#3 (11) {
  ["name"]=>
  string(2) "id"
  ["orgname"]=>
  string(2) "id"
  ["table"]=>
  string(9) "producten"
  ["orgtable"]=>
  string(9) "producten"
  ["def"]=>
  string(0) ""
  ["max_length"]=>
  int(4)
  ["length"]=>
  int(11)
  ["charsetnr"]=>
  int(63)
  ["flags"]=>
  int(49699)
  ["type"]=>
  int(3)
  ["decimals"]=>
  int(0)
}

-- 
Edit bug report at http://bugs.php.net/?id=39643&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=39643&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=39643&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=39643&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=39643&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=39643&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=39643&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=39643&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=39643&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=39643&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=39643&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=39643&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=39643&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=39643&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=39643&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=39643&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=39643&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=39643&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=39643&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=39643&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=39643&r=mysqlcfg

Reply via email to