ID:               29215
 User updated by:  rudy dot metzger at xs4all dot nl
 Reported By:      rudy dot metzger at xs4all dot nl
-Status:           Bogus
+Status:           Open
 Bug Type:         MySQL related
 Operating System: Linux RH ES 3
 PHP Version:      5.0.0
 New Comment:

parlnx03> select version();
+-------------------------+
| version()               |
+-------------------------+
| 4.1.3-beta-standard-log |
+-------------------------+
1 row in set (0.00 sec)
 
parlnx03> show create table test;
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                           |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| test  | CREATE TABLE `test` (
  `a` varchar(50) default NULL,
  `b` int(11) default NULL,
  `c` datetime default NULL,
  `d` float default NULL,
  `e` text
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
 
parlnx03>


Do not insert any data into the table (in practise, it does not matter
if you insert data or not, the result will be the same)

[command] php --version
PHP 5.0.0 (cli) (built: Jul 16 2004 13:57:08)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.0, Copyright (c) 1998-2004 Zend Technologies

<?php
 
  $dbh = mysql_connect( 'localhost', 'myself', 'mypwd' );
  mysql_select_db( 'test' );
 
  $sql = "SELECT a, b, c, d, e
            FROM test
           LIMIT 1";
  $res = mysql_unbuffered_query( $sql, $dbh );
 
  echo "Following is off by one index!\n";
 
  echo mysql_field_type( $res, 0 )." -> should be A, but is B\n";
  echo mysql_field_type( $res, 1 )." -> should be B, but is C\n";
  echo mysql_field_type( $res, 2 )." -> should be C, but is D\n";
  echo mysql_field_type( $res, 3 )." -> should be D, but is E\n";
  echo mysql_field_type( $res, 4 )." ALWAYS real";
 
  echo " NOTE: A is missing!\n";
 
  mysql_free_result( $res );
 
  mysql_close( $dbh );
 
?>

---------------- SCRIPT OUTPUT --------------------------

[command] php db.php
Following is off by one index!
int -> should be A, but is B
datetime -> should be B, but is C
real -> should be C, but is D
blob -> should be D, but is E
real ALWAYS real NOTE: A is missing!

---------------- END OUTPUT -----------------------------

As you can see, the output is off by one index (actually, the first
field should be -1). The last field is always real  (cannot mapped
anymore, because index is off). At MySQL 4.1.2 alpha the last one was
random (real, unknown, ..)

An easy way to reproduce:
1) create the table
2) modify the script with your userid/pwd
3) run the script

Happy debugging! And hope I could be of some help.

Cheerio
/rudy


Previous Comments:
------------------------------------------------------------------------

[2004-07-16 18:35:58] [EMAIL PROTECTED]

Please use actual mysql version for server and client 
(4.1.3-beta). If you will be able to reproduce the bug, 
send a reproducable and short testscript (including create 
table statement, and insert statement, output of client 
and server version) and reopen this bug. 

------------------------------------------------------------------------

[2004-07-16 16:30:42] rudy dot metzger at xs4all dot nl

Description:
------------
mysql_file_type() returns bogus data. 

PHP 5.0.0

mysql> desc zpm_auth;
+----------+-------------+------+-----+---------------------+-------+
| Field    | Type        | Null | Key | Default             | Extra |
+----------+-------------+------+-----+---------------------+-------+
| userid   | varchar(20) |      | PRI |                     |       |
| username | varchar(50) | YES  |     | NULL                |       |
| password | varchar(32) | YES  |     | NULL                |       |
| creusr   | varchar(32) |      |     |                     |       |
| credat   | datetime    |      |     | 0000-00-00 00:00:00 |       |
| modusr   | varchar(32) |      |     |                     |       |
| moddat   | datetime    |      |     | 0000-00-00 00:00:00 |       |
+----------+-------------+------+-----+---------------------+-------+
7 rows in set (0.00 sec)
 
mysql> select version();
+--------------------------+
| version()                |
+--------------------------+
| 4.1.2-alpha-standard-log |
+--------------------------+
1 row in set (0.00 sec)
 
mysql>



  $sql = "SELECT userid FROM zpm_auth LIMIT 1";
  $res = mysql_query( $sql, $this->DBH() );
  $this->EvaluateCommand( $res, false, true, $sql );
                                                                       
        
  $colType = mysql_field_type( $res, 0 );
die( $colType );


Works in PHP5 RC3



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=29215&edit=1

Reply via email to