使用C语言在mysql中插入数据的有关问题

使用C语言在mysql中插入数据的有关问题

使用C语言在mysql中插入数据的问题

不知道为什么,没有错误,但是就是没有数据插入。。

我的数据库结构是id(设置的自增)、name、age、sex。

求各位大神帮个忙查一下,哪里出了问题,多谢!

程序如下:

#include <stdio.h>

#include <stdlib.h>

#include “/usr/include/mysql/mysql.h”

int main (int argc, char *argv[])

{

  MYSQL my_connection;

  int res;

  mysql_init(&my_connection);

// if ((&my_connection = mysql_init(NULL)) ==NULL)

// {

// printf(“cannot initialize mysql!n”);

// return 1;

// }

  if (!mysql_real_connect(&my_connection,”localhost”,”root”,”123″,”db_friends”,0,NULL,0))

  {

  printf(“%d-%sn”,mysql_errno(&my_connection),mysql_error(&my_connection));

  return 1;

  printf(“connect success!n”);

  res = mysql_query(&my_connection,”insert into basic value(‘abc’,10,m)”);

  }

}




打印出来你的sql看看




res = mysql_query(&my_connection,”insert into basic value(‘abc’,10,m)”);




insert into basic values(null,’abc’,10,m);

使用C语言在mysql中插入数据的有关问题

相关文章:

你感兴趣的文章:

标签云: