I would like to insert into my database the character stored inside the variable t. How do I do that?
This is my code.
Thanks
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(("%s",1001,now(),'0')",t);
mysql_close(conn);
printf("%s",t);
_getch();
Comment