如何在C中清理SQL查询?
可能重复:
在C中防止SQL注入
我知道PHP有一些内置函数可以帮助清理查询,但C有这样的东西吗?
snprintf(&buff[0],1023,"UPDATE grades SET grade='%c' WHERE username='%s'",choice,&uname[0]); if (mysql_query(connect,&buff[0]) != 0) { // If it failed, tell the user printf("Error: %s!\n", mysql_error(connect)); return; }
MySQL C API有一个mysql_real_escape_string()
函数。
C语言和运行时没有这样的例程。 您的特定数据库的特定客户端库可能有一些东西。