php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #2661 mysql_fetch_field maxlength returns length of data, not max length of field
Submitted: 1999-11-04 02:05 UTC Modified: 1999-11-05 16:55 UTC
From: mbritton at verinet dot com Assigned:
Status: Closed Package: MySQL related
PHP Version: 3.0.12 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mbritton at verinet dot com
New email:
PHP Version: OS:

 

 [1999-11-04 02:05 UTC] mbritton at verinet dot com
<?php
$host = "localhost";
$user = "nobody";
$database = "varsity";
$password = "";
$conn = mysql_connect($host,$user,$password);
$result = mysql_db_query($database,"select * from people");
while ($row = mysql_fetch_row($result)) {
   for ( $i = 0; $i < mysql_num_fields($result); $i++ ) {
      $field_info = mysql_fetch_field($result,$i);
      print "field,len,value = $field_info->name,$field_info->max_length,$row[$i]<BR>";
   }
}
?>
---------------
OUTPUT:
field,len,value = person_id,1,1
field,len,value = lname,7,Britton
field,len,value = fname,5,Sandi
field,len,value = position,3,Mgr
---------------
Table Desc from mySQL:
+-----------+-------------+------+-----+---------+----------------+
| Field     | Type        | Null | Key | Default | Extra          |
+-----------+-------------+------+-----+---------+----------------+
| person_id | int(11)     |      | PRI | 0       | auto_increment |
| lname     | varchar(50) | YES  |     | NULL    |                |
| fname     | varchar(50) | YES  |     | NULL    |                |
| position  | varchar(50) | YES  |     | NULL    |                |
+-----------+-------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)

mysql> 


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-11-05 16:55 UTC] rasmus at cvs dot php dot net
I am unable to duplicate this bug.  It can only be a MySQL version issue as far as I can tell.  The exact test case you provided worked fine on PHP-3.0.13/MySQL-3.22.21
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 10 16:01:32 2024 UTC