msql C API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • poreko
    New Member
    • Nov 2006
    • 38

    msql C API

    Hi Guys,

    I would like to insert into my database the character stored inside the variable t. How do I do that?
    This is my code.
    Code:
    /*#include <my_global.h>
    #include <mysql.h>
    #include<time.h>
    #include<stdio.h>
    int main(int argc, char **argv)
    {
    char t="alpha"; 
    MYSQL *conn;
    
    conn = mysql_init(NULL);
    mysql_real_connect(conn, "localhost", "root", "", "testdb2", 0, NULL, 0);
    mysql_query(conn, "CREATE TABLE csetech_test (id int not null auto_increment,name varchar(20), password int,time varchar (20),sensor varchar(10), primary key(id))");
    mysql_query(conn, "INSERT INTO csetech_test(name,password,time, sensor) VALUES(&t,1701,now(),'0')");
    
    mysql_close(conn);
    
    }
Working...