[Mysql Api] Problem with tables listing

K

kilian

Hello,


I posted this message in alt.comp.databases.mysql but I fear that very
few peoples are visiting this newsgroup at this time...
So I rewrite my message here:

I'm a newbie with the C API (I program under Debian Sarge with Gcc-3.3.5)

I have a database which called "loges" and I would like to list the
tables in the shell's output (with printf).

Like that:

table1
table2
table3


But on the output I just get that:

tables_in_loges

I don't know where is my error...

Here is my source:


/*******************************/



MYSQL mysql_handle;
MYSQL_FIELD *tables;
MYSQL_RES *result;

unsigned int nb_tables;
mysql_init(&mysql_handle);

// login_datas is a structure with my username, password etc...
if(!mysql_real_connect(&mysql_handle,login_datas.host,login_datas.
user,login_datas.password,login_datas.database,3386,NULL,0))
{
printf("Erreur1\n");
}

result=mysql_list_tables(&mysql_handle,NULL);
if (result==NULL){
printf("Error2\n");
}

if (result)
{
nb_tables=mysql_num_fields(result);
}
tables=mysql_fetch_fields(result);
for (i=0;i<nb_tables;i++)
{
printf("%s\n",tables);
}

/****************************************/

Thanks....
 
S

SM Ryan

# Hello,
#
#
# I posted this message in alt.comp.databases.mysql but I fear that very
# few peoples are visiting this newsgroup at this time...
# So I rewrite my message here:
#
# I'm a newbie with the C API (I program under Debian Sarge with Gcc-3.3.5)
#
# I have a database which called "loges" and I would like to list the
# tables in the shell's output (with printf).
#
# Like that:
#
# table1
# table2
# table3
#
#
# But on the output I just get that:
#
# tables_in_loges
#
# I don't know where is my error...
#
# Here is my source:

mysql_fetch_fields returns information about what each column is.

Use mysql_fetch_row and mysql_fetch_lengths to fetch each row of output
as an array of column contents.
 
K

kilian

SM said:
mysql_fetch_fields returns information about what each column is.

Use mysql_fetch_row and mysql_fetch_lengths to fetch each row of output
as an array of column contents.

Aaah right!

Thank you... it works now :)
 
C

CBFalconer

kilian said:
I posted this message in alt.comp.databases.mysql but I fear that
very few peoples are visiting this newsgroup at this time...

That may very well be because too many people posted off topic
garbage there and were not told it was off topic and to go to a
suitable newsgroup. This tends to drive away the people who want
to discuss the group subject.

You are off topic here. Read the following references for clues.

--
Some useful references about C:
<http://www.ungerhu.com/jxh/clc.welcome.txt>
<http://www.eskimo.com/~scs/C-faq/top.html>
<http://benpfaff.org/writings/clc/off-topic.html>
<http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/> (C99)
<http://www.dinkumware.com/refxc.html> (C-library}
<http://gcc.gnu.org/onlinedocs/> (GNU docs)
 
M

Martijn

I posted this message in alt.comp.databases.mysql but I fear that
You are off topic here. Read the following references for clues.

The OP might want to try comp.programming, which is more general.
 
K

kilian

CBFalconer said:
That may very well be because too many people posted off topic
garbage there and were not told it was off topic and to go to a
suitable newsgroup. This tends to drive away the people who want
to discuss the group subject.

You are off topic here. Read the following references for clues.

Ok sorry for the off-topic...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,999
Latest member
MakersCBDGummiesReview

Latest Threads

Top