Article View: apana.lists.os.linux.c-programming
Article #1Mysql failed access with C
From: Alberto
Date: Wed, 12 May 1999 00:00
Date: Wed, 12 May 1999 00:00
70 lines
3097 bytes
3097 bytes
I don't get to accede to Mysql table data with my program in C
Would I like to know How I can make it?.
This is the program that I use:
#include <stdio.h>
#include <stdlib.h>
#include <mysql.h>
MYSQL mysql;
MYSQL_RES *res;
MYSQL_ROW row;
void exiterr(int exitcode)
{
fprintf( stderr, "%s\n", mysql_error(&mysql) );
exit( exitcode );
}
int main()
{
uint i = 0;
if
(!(mysql_connect(&mysql,"host","username","password")))
exiterr(1);
if (mysql_select_db(&mysql,"payroll"))
exiterr(2);
if (mysql_query(&mysql,"SELECT name,rate FROM
emp_master"))
exiterr(3);
if (!(res = mysql_store_result(&mysql)))
exiterr(4);
while((row = mysql_fetch_row(res))) {
for (i=0 ; i < mysql_num_fields(res); i++)
printf("%s\n",row[i]);
}
if (!mysql_eof(res))
exiterr(5);
mysql_free_result(res);
mysql_close(&mysql);
}
It is compiled well, but it fails when being executed giving the following
error:
undefinder reference to mysql_error
undefinder reference to mysql_connect
undefinder reference to mysql_select_db
undefinder reference to mysql_query
undefinder reference to mysql_store_result
undefinder reference to mysql_fetch_row
undefinder reference to mysql_num_fields
undefinder reference to mysql_eof
undefinder reference to mysql_free_result
undefinder reference to mysql_close
Mysql lib is well and also the path to accede.
Is the strangest thing that it sometimes executes well it and other not,
why?
Thanks...
Technical Details
Message-ID:
<7habmq$pak$1@talia.mad.ttd.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fdf5c,176d052e58b206de,start X-Google-Attributes: gidfdf5c,public X-Google-Thread: 109d22,176d052e58b206de,start X-Google-Attributes: gid109d22,public X-Google-Thread: 10b1d3,176d052e58b206de,start X-Google-Attributes: gid10b1d3,public X-Google-Thread: 10ddee,176d052e58b206de,start X-Google-Attributes: gid10ddee,public X-Google-Thread: 10ce1c,176d052e58b206de,start X-Google-Attributes: gid10ce1c,public X-Google-Thread: 1148a8,176d052e58b206de,start X-Google-Attributes: gid1148a8,public From: "Alberto" <agarrido@svalero.es> Subject: Mysql failed access with C Date: 1999/05/12 Message-ID: <7habmq$pak$1@talia.mad.ttd.net> X-Deja-AN: 476779241 Organization: Telefonica Transmision de Datos X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Newsgroups: apana.lists.os.linux.c-programming,ba.php,dk.edb.programmering.c,fr.comp.infosystemes.www.auteurs.php,no.it.programmering.c,ufra.lists.php