473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

mysql_fetch_fields issue

Hi,

Somebody please help me. I have a table like this:

----------------
column1|column2|
---------------
1 | 2 |
----------------

Both columns are type int(11). And here's what I do:

sprintf(initial_query, "%s %s LIMIT 1", select * from", tablename);

if ((return = mysql_query(&dbmaster, initial_query)) != 0) {
exit(1);
}
if ((master = mysql_store_result(&dbmaster)) == 0) {
exit(1);
}
if ((master_fields = mysql_fetch_fields(master)) == NULL) {
exit(1);
}
master_column = mysql_num_fields(master);
//master_column = mysql_field_count(&dbmaster);
mysql_free_result(master);

for (i=0; i<master_column; i++) {
printf ("field %d type is %d", i, master_fields[i].type);
printf ("field %d name is %s", i, master_fields[i].name);
}

This is just a snippet. Every variable is declared correctly. Here,
as expected, I get 2 as the return value for mysql_num_fields or
mysql_field_count. However, in the for loop, I get weird values for
field type and get NULL for second column name:

Field 0 type is 134557680 Field 0 name is column1
Field 1 type is 3239533 Field 1 name is (null)

WHAT IS GOING ON? I am at a loss. Could this be a bug in MySQL? I'd
appreciate it if someone can shed some light on this? Thanks!

-j.
Jul 19 '05 #1
2 3813
cs***@yahoo.com (James Lee) wrote in message news:<14**************************@posting.google. com>...
Hi,

Somebody please help me. I have a table like this:

----------------
column1|column2|
---------------
1 | 2 |
----------------

Both columns are type int(11). And here's what I do:

sprintf(initial_query, "%s %s LIMIT 1", select * from", tablename);

if ((return = mysql_query(&dbmaster, initial_query)) != 0) {
exit(1);
}
if ((master = mysql_store_result(&dbmaster)) == 0) {
exit(1);
}
if ((master_fields = mysql_fetch_fields(master)) == NULL) {
exit(1);
}
master_column = mysql_num_fields(master);
//master_column = mysql_field_count(&dbmaster);
mysql_free_result(master);

for (i=0; i<master_column; i++) {
printf ("field %d type is %d", i, master_fields[i].type);
printf ("field %d name is %s", i, master_fields[i].name);
}

This is just a snippet. Every variable is declared correctly. Here,
as expected, I get 2 as the return value for mysql_num_fields or
mysql_field_count. However, in the for loop, I get weird values for
field type and get NULL for second column name:

Field 0 type is 134557680 Field 0 name is column1
Field 1 type is 3239533 Field 1 name is (null)

WHAT IS GOING ON? I am at a loss. Could this be a bug in MySQL? I'd
appreciate it if someone can shed some light on this? Thanks!

-j.


I have come to a conclusion that this is a bug in MySQL. It doesn't
fetch the fields right if there are more than one column. Also, even
if there is only one column it doesn't store the right information to
MYSQL_FIELD struct, for example, type. Any comments? BTW,
master_fields is of type MYSQL_FIELD *. Thanks.

-j.
Jul 19 '05 #2
cs***@yahoo.com (James Lee) wrote in message news:<14**************************@posting.google. com>...
Hi,

Somebody please help me. I have a table like this:

----------------
column1|column2|
---------------
1 | 2 |
----------------

Both columns are type int(11). And here's what I do:

sprintf(initial_query, "%s %s LIMIT 1", select * from", tablename);

if ((return = mysql_query(&dbmaster, initial_query)) != 0) {
exit(1);
}
if ((master = mysql_store_result(&dbmaster)) == 0) {
exit(1);
}
if ((master_fields = mysql_fetch_fields(master)) == NULL) {
exit(1);
}
master_column = mysql_num_fields(master);
//master_column = mysql_field_count(&dbmaster);
mysql_free_result(master);

for (i=0; i<master_column; i++) {
printf ("field %d type is %d", i, master_fields[i].type);
printf ("field %d name is %s", i, master_fields[i].name);
}

This is just a snippet. Every variable is declared correctly. Here,
as expected, I get 2 as the return value for mysql_num_fields or
mysql_field_count. However, in the for loop, I get weird values for
field type and get NULL for second column name:

Field 0 type is 134557680 Field 0 name is column1
Field 1 type is 3239533 Field 1 name is (null)

WHAT IS GOING ON? I am at a loss. Could this be a bug in MySQL? I'd
appreciate it if someone can shed some light on this? Thanks!

-j.


I have come to a conclusion that this is a bug in MySQL. It doesn't
fetch the fields right if there are more than one column. Also, even
if there is only one column it doesn't store the right information to
MYSQL_FIELD struct, for example, type. Any comments? BTW,
master_fields is of type MYSQL_FIELD *. Thanks.

-j.
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: James Lee | last post by:
Hi, Somebody please help me. I have a table like this: ---------------- column1|column2| --------------- 1 | 2 | ----------------
3
by: Paul Mateer | last post by:
Hi, I have been running some queries against a table in a my database and have noted an odd (at least it seems odd to me) performance issue. The table has approximately 5 million rows and...
7
by: George Hester | last post by:
Please take a look at this google artcle: http://groups.google.com/groups?hl=en&lr=&frame=right&th=55d6f4b50f5f9382&seekm=411f370d%241%40olaf.komtel.net#link9 The op was having trouble with...
2
by: Anthony Cuttitta Jr. | last post by:
We have an application that outputs several different graphs from data downloaded from our AS400. The application has worked without (this) issue for several months now, but just recently, the...
0
by: Kevin Spencer | last post by:
Hi all, I am working on a service that uploads METAR weather information to the National Weather Service FTP site. The service I'm authoring is hosted on a Windows 200 server, and the NWS FTP...
2
by: Ben Rush | last post by:
Hello World, Okay, I have spent the day browsing the newsgroups and reading up on article after article concerning ViewState corruption and so forth, and I have a couple questions. We...
5
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant...
0
by: Charles Leonard | last post by:
I am having yet another issue with Windows Server 2003. This time, the web service (a file import web service) appears to run except for one odd message: "ActiveX component can't create object". ...
4
by: Paul | last post by:
Hi, I've been struggling with this today, I'm developing a DotNet2.0 website in C# that needs to call a long running data query. Obviously this is a good candidate for an Asynchronous call, so...
13
by: SAL | last post by:
Hello, I'm trying to include a popup in the ItemTemplate of a gridview row. The ItemTemplate for the field contains a textbox and when the user clicks in the textbox I want a popup panel to show...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.