Results 1 to 2 of 2

Thread: how to connect mysql to my c program ...

  1. #1
    Junior Member
    Join Date
    Feb 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    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);





    }

  2. #2
    Never say die nixcraft's Avatar
    Join Date
    Jan 2005
    Location
    BIOS
    Posts
    4,513
    Thanks
    17
    Thanked 807 Times in 511 Posts
    Rep Power
    10
    All [Solved] threads are closed by mods / admin to avoid spam issues. See Howto mark a thread as [Solved]


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. is any one good in c program ?
    By oronno in forum Shell scripting
    Replies: 0
    Last Post: 19th September 2007, 01:04 PM
  2. Connect mysql in c
    By raj in forum Databases servers
    Replies: 1
    Last Post: 10th August 2007, 08:10 PM
  3. start program
    By schaapmansz in forum Getting started tutorials
    Replies: 1
    Last Post: 26th June 2007, 09:49 PM
  4. mysql connect failed for root
    By raghuram in forum Databases servers
    Replies: 1
    Last Post: 15th February 2007, 11:06 AM
  5. Replies: 1
    Last Post: 17th July 2006, 02:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •