Connecting Tech Pros Worldwide Forums | Help | Site Map

msql C API

Member
 
Join Date: Nov 2006
Posts: 38
#1: Jan 14 '09
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.
Expand|Select|Wrap|Line Numbers
  1. /*#include <my_global.h>
  2. #include <mysql.h>
  3. #include<time.h>
  4. #include<stdio.h>
  5. int main(int argc, char **argv)
  6. {
  7. char t="alpha"; 
  8. MYSQL *conn;
  9.  
  10. conn = mysql_init(NULL);
  11. mysql_real_connect(conn, "localhost", "root", "", "testdb2", 0, NULL, 0);
  12. 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))");
  13. mysql_query(conn, "INSERT INTO csetech_test(name,password,time, sensor) VALUES(&t,1701,now(),'0')");
  14.  
  15. mysql_close(conn);
  16.  
  17. }
  18.  

Reply