php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #743 fields wrongly parsed when Decimal(x,x) defined in table
Submitted: 1998-09-13 15:15 UTC Modified: 1998-09-22 14:50 UTC
From: analyzer at kemuri dot net Assigned:
Status: Closed Package: MySQL related
PHP Version: 3.0.3 OS: linux
Private report: No CVE-ID: None
 [1998-09-13 15:15 UTC] analyzer at kemuri dot net
Hi,

When I'm asking the fieldnames of a Mysql table, the lists stops
when a decimal-fields has been reached.

This is the output:

productid 20
 name 255
 sourceurl 255
 price 8

This is the table definition:

productid	varchar(20) not null,
name varchar(255) not null,
sourceurl	varchar(255),
price decimal(8,2),
vat varchar(3),
weight decimal(5,2),
category mediumint,
min2order tinyint,
options text,

I guess the comma is wrong in Decimal..
Here's is a piece of code for version 3.0.3..

Kind Regards,

Geert

<?

$MY = mysql_pconnect("localhost","analyzer","AnA56g!");
mysql_select_db("linuxcorner",$MY);

function ProductForm($productid) {
 global $MY;

 $res = mysql_query("select * from products",$MY);

 $fieldsnr = mysql_list_fields("linuxcorner", "products");

 echo '<TABLE BORDER="0">';

 for($i=0; $i <= $fieldsnr; $i++) {
   $fname = mysql_field_name($res,$i);
   $flength = mysql_field_len($res, $i);
   echo "<TR><TD>$fname $flength</TD>\n";
	"</TR>";
 }

 echo '</TABLE>';
}

ProductForm("blah");

?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-09-22 14:50 UTC] zeev
This script makes no sense.  I've fixed it up and it works
exactly as expected:

<?

$MY = mysql_connect(...);
mysql_select_db("foo",$MY);

function ProductForm($productid) {
 global $MY;

 $res = mysql_list_fields("foo", "bar") or die(mysql_error());
 $fieldsnr = mysql_num_fields($res);

 echo '<TABLE BORDER="0">';

 for($i=0; $i < $fieldsnr; $i++) {
   $fname = mysql_field_name($res,$i);
   $flength = mysql_field_len($res, $i);
   echo "<TR><TD>$fname $flength</TD>\n";
        "</TR>";
 }

 echo '</TABLE>';
}

ProductForm("blah");

?>

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Jun 26 03:01:26 2019 UTC