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
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: analyzer at kemuri dot net
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sat May 10 01:01:28 2025 UTC