Re: C API Query Semantics

2003-06-19 Thread gerald_clark
Look at the source for the mysql client.
It is a perfect example.
Sean Macmillan wrote:

Using the C API I have written a program that calls mysql_query() on a 
table with values I know to be in the table.  It returns fine and I 
then call mysql_store_result.  The problem I am having is figuring out 
how to dump the contents of that query to the screen (printf for 
example).  I have tried mysql_fetch_rows and a few others.  What am 
trying to do is see the data on the terminal once the c program 
executes.  Any suggestions?

Sean Mac Millan




--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


RE: C-API Query

2002-01-07 Thread John Lodge

Hello,

I have corrected the code as I would have written it. Also are you sure the
file mysql.h
is where you think it is?

#include stdio.h
#include mysql/mysql.h

main()
{
   int sel;
   MYSQL mysql=NULL;
   MYSQL *connection;
 MYSQL_RES *result;
 mysql_init(mysql);
   if(mysql == NULL)
   { 
printf(\n MySQL unable to intialise\n);
exit(-1);
}

connection=mysql_real_connect(mysql,23.22.2.2,user,pwd,db_name,0,NU
LL,0);
sel = mysql_query(connection, select e-no,ename from employee);
printf(sel %d\n,sel);
}

John Lodge

-Original Message-
From: udayashankarl_n [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 07, 2002 11:51 AM
To: [EMAIL PROTECTED]
Subject: C-API Query


Hi,
I have written the following code using C-API and would like to retrieve
the info from MYSQL.
But it gives me error messages. Please let me know where iam going
wrong.
the code and error messages are :
#include stdio.h
#include mysql/mysql.h

main()
{
int sel;
MYSQL *mysql=NULL;
mysql_init(mysql);
if(mysql == NULL)
{ 
printf(\n MySQL unable to intialise\n);
exit(-1);
}

mysql_real_connect(mysql,23.22.2.2,user,pwd,db_name,0,NULL,0);
sel = mysql_query(mysql, select e-no,ename from employee);
printf(sel %d\n,sel);
}

produces the following error messages.

/tmp/ccPhnnJk.o: In function `main':
/tmp/ccPhnnJk.o(.text+0x14): undefined reference to `mysql_init'
/tmp/ccPhnnJk.o(.text+0x5a): undefined reference to `mysql_real_connect'
/tmp/ccPhnnJk.o(.text+0x6d): undefined reference to `mysql_query'
collect2: ld returned 1 exit status

Regards
Uday

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: C-API Query

2002-01-07 Thread Aigars Grins

Hi,

[..]
 produces the following error messages.

 /tmp/ccPhnnJk.o: In function `main':
 /tmp/ccPhnnJk.o(.text+0x14): undefined reference to `mysql_init'
 /tmp/ccPhnnJk.o(.text+0x5a): undefined reference to `mysql_real_connect'
 /tmp/ccPhnnJk.o(.text+0x6d): undefined reference to `mysql_query'
 collect2: ld returned 1 exit status
[..]

I would think that the error message is from ld (the linker). So, it's not a
fault in your code per se, but rather the arguments to the linker. Have you
stated to include the mysql library? Using gcc it could be something like:
-L/usr/local/lib/mysql -lmysqlclient.

--
Aigars

DISCLAIMER:

Internet communications are not secure and therefore Defcom does not accept
legal responsibility for the contents or accuracy of this message. The views
and opinions contained in the message are solely those of the author and do
not necessarily represent those of Defcom unless otherwise specifically
stated.


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php