🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: apana.lists.os.linux.c-programming
1 messages
1 total messages Started by Alberto Wed, 12 May 1999 00:00
Mysql failed access with C
#1
Author: Alberto
Date: Wed, 12 May 1999 00:00
70 lines
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...
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads