我对mysql数据库有疑问。当我尝试使用以下函数MYSQL_BIND时,出现以下错误
MySQL查询错误:您的SQL语法出错;检查 手册,对应右边的MySQL服务器版本 在第1行“?,?)”附近使用的语法
我一直在寻找网络,到目前为止我还没有找到解决问题的方法。我想我在查询query = "INSERT INTO users (num1, num2) values (?, ?)";
代码在c ++中
MYSQL *conn; // the connection
MYSQL_RES *res; // the results
MYSQL_ROW row; // the results row (line by line)
MYSQL_STMT *stmt;
MYSQL_BIND params[2];
char *query;
int var1 = 222;
int var2 = 55;
struct connection_details mysqlD;
mysqlD.server = "localhost"; // where the mysql database is
mysqlD.user = "root"; // the root user of mysql
mysqlD.password = "pass1"; // the password of the root user in mysql
mysqlD.database = "db1"; // the databse to pick
// connect to the mysql database
conn = mysql_connection_setup(mysqlD);
memset(params, 0, sizeof(params));
query = "INSERT INTO users (num1, num2) values (?, ?)";
params[0].buffer = &var1;
params[0].buffer_type = MYSQL_TYPE_LONG;
params[1].buffer = &var1;
params[1].buffer_type = MYSQL_TYPE_LONG;
// assign the results return to the MYSQL_RES pointer
//res = mysql_perform_query(conn, "show tables");
mysql_perform_query(conn, query);
我将非常感谢你的帮助