nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

how to connect mysql to my c program ...

This is a discussion on how to connect mysql to my c program ... within the Databases servers forums, part of the Mastering Servers category; hi everyone... Can anyone help me to build the code to link my c language to the mysql server...this program ...


Go Back   nixCraft Linux Forum > Mastering Servers > Databases servers

Linux answers from nixCraft.


Databases servers Discussions of databases of all types - especially MySQL.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 13-02-2009, 11:10 AM
Junior Member
User
 
Join Date: Feb 2009
OS: ubuntu
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
malekcw is on a distinguished road
Default how to connect mysql to my c program ...

hi everyone...

Can anyone help me to build the code to link my c language to the mysql server...this program wiill receive the data from the RFID tag using the serial connection then the data will send into mysql server.. now i dont now how to write the program to connection to mysql server .... Can you all help me....



this my code to get the data from serial ..

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <stdio.h>
#include <string.h>



#define BAUDRATE B2400
#define MODEMDEVICE "/dev/ttyr01"
#define _POSIX_SOURCE 1
#define FALSE 0
#define TRUE 1

volatile int STOP=FALSE;
main()
{
int fd,c,res,i;
struct termios oldtio , newtio;
char buf[20];
FILE *fid;


fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY);
if (fd<0) {perror(MODEMDEVICE);
exit(-1);
}

tcgetattr (fd,&oldtio);
bzero(&newtio, sizeof(newtio));
newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD;
newtio.c_iflag = IGNPAR | ICRNL;
newtio.c_oflag = 0;
newtio.c_lflag = ICANON;

tcflush(fd, TCIFLUSH);
tcsetattr (fd,TCSANOW, &newtio);


char id [16];
printf("Opening COm Port : %s\n\n",MODEMDEVICE);
fid = fopen ("data1.dat","w+");
if (fid<0)
printf ("Error \n");
while (STOP==FALSE)
{

res = read(fd,buf,16);
buf[res]=0;
strcpy(id,buf);
fprintf(fid,"ID: %\n", id);
printf("ID: %s\n", buf);

}

fclose(fid);

tcsetattr(fd,TCSANOW,&oldtio);





}
Reply With Quote
  #2 (permalink)  
Old 23-02-2009, 11:32 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 246 Times in 184 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

http://www.cyberciti.biz/tips/linux-...i-program.html
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
is any one good in c program ? oronno Shell scripting 0 19-09-2007 01:04 PM
Connect mysql in c raj Databases servers 1 10-08-2007 08:10 PM
start program schaapmansz Getting started tutorials 1 26-06-2007 09:49 PM
mysql connect failed for root raghuram Databases servers 1 15-02-2007 11:06 AM
Failed in mysql_real_connect(): Can't connect to local MySQL Linux software 1 17-07-2006 02:05 AM


All times are GMT +5.5. The time now is 06:32 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38