如何通过 C++要插入 c++ 的变量使用 Mysql ++
几天来我一直在努力处理代码,任何人都可以帮助
std::string str=uri_req1.substr(found+1);
char query[2000];
sprintf(query,"Insert into publish VALUES('%s','NO')",str);
我收到以下警告,并且值未插入到表中,
warning: cannot pass objects of non-POD type ‘struct std::string’
through ‘...’; call will abort at runtime
warning: format ‘%s’ expects type ‘char*’, but
argument 3 has type ‘int’
我尝试过其他事情,
string query;
query="Insert into publish values('";
query+=str;
query+="','NO')";
mysql_query(&mysql,query);
但这也从未奏效 请帮忙
I am struggling with the code from few days can anyone help
std::string str=uri_req1.substr(found+1);
char query[2000];
sprintf(query,"Insert into publish VALUES('%s','NO')",str);
I am getting following warnings and value is not inserted in the tables
warning: cannot pass objects of non-POD type ‘struct std::string’
through ‘...’; call will abort at runtime
warning: format ‘%s’ expects type ‘char*’, but
argument 3 has type ‘int’
other thing I tried was
string query;
query="Insert into publish values('";
query+=str;
query+="','NO')";
mysql_query(&mysql,query);
but this also never worked
kindly help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我可能会使用 stringstream 来组装字符串:
I'd probably use a stringstream to assemble the string:
这肯定会起作用;)
This will surely work ;)