Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/138.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
mysql/mysql.hc++;错误 这是我的C++代码用于MySQL插入的一个片段。我找到了一个如何使用mysql.h的例子。程序运行良好,直到我为mysql添加以下内容。我是C++新手,在其他代码中发现了同样的例子,只是不能确定问题我添加了MySQL/MySQL .h,而不是MySQL .h,还有-I和-L,通过网络编译,仍然没有运气。任何帮助都将不胜感激 #include <mysql/mysql.h> string unknown = "Unknown" MYSQL *conn; conn = mysql_init(NULL); mysql_real_connect(conn, "localhost", "root", "password", "alert", 0, NULL, 0); mysql_query(conn, "INSERT INTO alert_tbl (alert_srcip, alert_country, alert_destip, alert_desthost, alert_destport, alert_bl) VALUES ('%s','%s','%s','%s','%s','%s')", src_ip,country_code,dest_ip,unknown,dest_prt,blip); mysql_close(conn); #包括 string unknown=“unknown” MYSQL*康涅狄格州; conn=mysql_init(NULL); mysql\u real\u connect(conn,“localhost”,“root”,“password”,“alert”,0,NULL,0); mysql查询(conn,“插入警报tbl(警报srcip、警报国家/地区、警报目的地、警报目的地主机、警报目的地端口、警报目的地)值('%s'、'%s'、'%s'、'%s'、'%s'、'%s'、'%s'、'%s')、警报目的地ip、国家/地区代码、目的地ip、未知、目的地prt、blip); 关闭(康涅狄格州);_C++_Mysql_Linux - Fatal编程技术网

mysql/mysql.hc++;错误 这是我的C++代码用于MySQL插入的一个片段。我找到了一个如何使用mysql.h的例子。程序运行良好,直到我为mysql添加以下内容。我是C++新手,在其他代码中发现了同样的例子,只是不能确定问题我添加了MySQL/MySQL .h,而不是MySQL .h,还有-I和-L,通过网络编译,仍然没有运气。任何帮助都将不胜感激 #include <mysql/mysql.h> string unknown = "Unknown" MYSQL *conn; conn = mysql_init(NULL); mysql_real_connect(conn, "localhost", "root", "password", "alert", 0, NULL, 0); mysql_query(conn, "INSERT INTO alert_tbl (alert_srcip, alert_country, alert_destip, alert_desthost, alert_destport, alert_bl) VALUES ('%s','%s','%s','%s','%s','%s')", src_ip,country_code,dest_ip,unknown,dest_prt,blip); mysql_close(conn); #包括 string unknown=“unknown” MYSQL*康涅狄格州; conn=mysql_init(NULL); mysql\u real\u connect(conn,“localhost”,“root”,“password”,“alert”,0,NULL,0); mysql查询(conn,“插入警报tbl(警报srcip、警报国家/地区、警报目的地、警报目的地主机、警报目的地端口、警报目的地)值('%s'、'%s'、'%s'、'%s'、'%s'、'%s'、'%s'、'%s')、警报目的地ip、国家/地区代码、目的地ip、未知、目的地prt、blip); 关闭(康涅狄格州);

mysql/mysql.hc++;错误 这是我的C++代码用于MySQL插入的一个片段。我找到了一个如何使用mysql.h的例子。程序运行良好,直到我为mysql添加以下内容。我是C++新手,在其他代码中发现了同样的例子,只是不能确定问题我添加了MySQL/MySQL .h,而不是MySQL .h,还有-I和-L,通过网络编译,仍然没有运气。任何帮助都将不胜感激 #include <mysql/mysql.h> string unknown = "Unknown" MYSQL *conn; conn = mysql_init(NULL); mysql_real_connect(conn, "localhost", "root", "password", "alert", 0, NULL, 0); mysql_query(conn, "INSERT INTO alert_tbl (alert_srcip, alert_country, alert_destip, alert_desthost, alert_destport, alert_bl) VALUES ('%s','%s','%s','%s','%s','%s')", src_ip,country_code,dest_ip,unknown,dest_prt,blip); mysql_close(conn); #包括 string unknown=“unknown” MYSQL*康涅狄格州; conn=mysql_init(NULL); mysql\u real\u connect(conn,“localhost”,“root”,“password”,“alert”,0,NULL,0); mysql查询(conn,“插入警报tbl(警报srcip、警报国家/地区、警报目的地、警报目的地主机、警报目的地端口、警报目的地)值('%s'、'%s'、'%s'、'%s'、'%s'、'%s'、'%s'、'%s')、警报目的地ip、国家/地区代码、目的地ip、未知、目的地prt、blip); 关闭(康涅狄格州);,c++,mysql,linux,C++,Mysql,Linux,c-o test-lstdc++-I/usr/include/mysql-L/usr/lib/mysql-lmysqlclient 测试c:错误:预期,或;MYSQL之前 test.c:错误:未在此作用域中声明conn test.c:错误:未在此范围内声明conn缺少分号: string unknown = "Unknown"; 调用mysql\u query的参数太多;它不是“printf”样式的函数。您可以使用sprintf来创建一个单独的缓冲区,但有可能会发生错误。你应该用。我觉得很愚蠢

c-o test-lstdc++-I/usr/include/mysql-L/usr/lib/mysql-lmysqlclient

测试c:错误:预期,或;MYSQL之前

test.c:错误:未在此作用域中声明conn

test.c:错误:未在此范围内声明conn

缺少分号:

string unknown = "Unknown";

调用
mysql\u query
的参数太多;它不是“printf”样式的函数。您可以使用sprintf来创建一个单独的缓冲区,但有可能会发生错误。你应该用。

我觉得很愚蠢,谢谢。我觉得自己就像办公室里的十进制事件。谢谢。mysql\u查询只接受两个参数。如果您打算像那样传递完整的字符串,则需要先使用sprintf,然后传递结果字符串。但是,这会导致SQL注入攻击的可能性。您应该使用参数化查询。