php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31518 The mysql_field_type, WRONG
Submitted: 2005-01-12 15:24 UTC Modified: 2005-01-14 14:47 UTC
From: mulder_bravo at yahoo dot com Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4.3.10 OS: Windows Xp - Service Pack1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mulder_bravo at yahoo dot com
New email:
PHP Version: OS:

 

 [2005-01-12 15:24 UTC] mulder_bravo at yahoo dot com
Description:
------------
When i get a data type, this dont show me the rigth value.
I have a LongText field, when I use mysql_field_type, this show me blob... why??

Reproduce code:
---------------
$ty=mysql_field_type($result,$i);
echo $ty;


Expected result:
----------------
I expected the right field name, LongText field...

Actual result:
--------------
blob

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-13 16:27 UTC] mulder_bravo at yahoo dot com
Ok..
I have this field on the database
CREATE TABLE opiv1 (
  idopinion INTEGER(10) UNSIGNED NOT NULL,
   comntario LONGTEXT NULL,
   PRIMARY KEY(idopinion)
);

when I apply a select function, I need the field name...
I use mysql_field_type on the data collect.

$numcampos=mysql_num_fields($result);
for ($i=0;$i<$numcampos;$i++){
 $cab=mysql_field_name($result,$i);
 echo "Field $i: $cab";
}

he most to write:

Field Int
Field LongText

and this show me

Field Int
Field Blob
 [2005-01-14 05:31 UTC] jed@php.net
We need more than this to begin handling this bug. Please tell us what MySQL version you are using, and give us a code snippet that matches your output.

$cab=mysql_field_name($result,$i);
echo "Field $i: $cab";
This wouldn't output "Field Int".

A working, minimal example would be beneficial in addition to your MySQL version.
 [2005-01-14 08:39 UTC] georg@php.net
Your sample is wrong: mysql_field_name returns the name of 
the field, not the type. 
 
Also the mysql_field functions return resultset metadata 
information, and not database metadata information. If you 
need to retrieve the defined columntype use MySQL's SQL 
functions for. 
 [2005-01-14 14:47 UTC] mulder_bravo at yahoo dot com
georg@php.net you are WRONG!!!!!

for ($i=0;$i<$numcampos;$i++){
 $cab=mysql_field_name($result,$i); // I use a right function
 echo "Field $i: $cab";
}

I work with mysql 4.0
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 13 12:01:27 2025 UTC