MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old May 24th, 2000, 07:57 AM
abbas abbas is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 19 abbas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
#include <stdio.h>
#include <stdlib.h>
#include "mysql.h"

MYSQL mysql;
MYSQL_RES *res;
MYSQL_ROW row;

void exiterr(int exitcode)
{
fprintf( stderr, "%sn", mysql_error(&mysql) );
exit( exitcode );
}

int main()
{
uint i = 0;

if (!(mysql_connect(&mysql,"host","username","password")))
exiterr(1);

if (mysql_select_db(&mysql,"ksedata"))
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("%sn",row[i]);
}

if (!mysql_eof(res))
exiterr(5);

mysql_free_result(res);
mysql_close(&mysql);
}


***************************************
when i compile above code following error messages come

undefined reference error mysql_connect(...)
undefined reference error mysql_bin(..)
etc...
whats wrong either my gcc is not link whith
client side lib or something else?
thanks in advance..

Reply With Quote
  #2  
Old May 24th, 2000, 08:16 AM
Kyuzo Kyuzo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: Annapolis, Maryland US
Posts: 113 Kyuzo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
What do your compiling and linking commands look like?

Did you pass the the mysql.h header file argument and client library argument in the compiling and linking steps, respectively so the compiler and linker can find the files?

Try something like....

gcc -c -I/usr/local/include/mysql program.c

gcc -o program program.o -L/usr/local/lib/mysql -lmysqlclient


Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > whats wrong in my code or compile method my code is here?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway