List:General Discussion« Previous MessageNext Message »
From:c0231 Date:May 21 2003 4:10pm
Subject:Newbie:how to get and print the result :(
View as plain text  
hello :
     i am learning to write my program with c-API of mysql4.0.11a,
     it is a very simple program , just do sth as
    mysql_query(&mysql,"select name from persons where id = %d")
    while after successful query ,i do know how to get the result !
    will you please give me some example of program ?
my program:
**********************
   ......
   mysql_init(&mysql);
 if (!(sock = mysql_real_connect(&mysql,NULL,0,0,argv[1],0,NULL,0)))
 {
 ...
 }
count=atoi(argv[2]);
sprintf(qbuf,SELECT_QUERY,count);
buffer=qbuf;
printf("%s\n",buffer);
if(mysql_query(sock,qbuf))
  {
     fprintf(stderr,"Query failed:%s\n",mysql_error(sock));
     exit(1);
   }
   if(!(result=mysql_store_result(&mysql)))
   {
     fprintf(stderr,"Couldn't get result from %s\n",mysql_error(&mysql));
     exit(1);
   }
   printf("%d products select\n",mysql_affected_rows(&mysql));

  *** and next ??? :( 

********************
   thanks a lot! 
Thread
Newbie:how to get and print the result :(c023121 May
  • Problem Compiling MySQL 4.0.13Victor Medina21 May
    • Re: Problem Compiling MySQL 4.0.13Lenz Grimmer21 May