SQL sprintf()语句 [英] SQL sprintf() Statement

查看:404
本文介绍了SQL sprintf()语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此语句未返回值.

This statement isn''t returning a value.

char buffer[500]; sprintf(buffer, "SELECT COUNT(*) FROM tblURLIP WHERE IP = %s And IPStatus = ''1'' AndIPMax = ''0''"), ipSrc, mysql_query(conn, buffer); 

推荐答案

char buffer[500]; 
/* use sprintf - (s)tring(print)(f)ormatted */
/* wrap the %s for ipsrc in quotes */ 
sprintf(buffer, "SELECT COUNT(*) FROM tblURLIP WHERE IP = ''%s'' And IPStatus = ''1'' AndIPMax = ''0''", ipSrc);
/* use the generated command */
mysql_query(conn, buffer);


很好.您是否考虑过使用C ++而不是C进行字符串处理?您是否考虑过检查SQL语句的外观并告诉我们结果语句是什么? IP不在引号中是对的吗?除了编写一些代码并要求我们为您修复代码以外,您是否做过其他事情?
Well, great. Did you consider using C++ instead of C for your string handling ? Did you consider checking what the SQL statement looks like and telling us what the resultant statement is ? Is it right that IP is not in quotes ? Have you done anything beyond writing some code and asking us to fix it for you ?


这篇关于SQL sprintf()语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆