如何在C中清理SQL查询? [英] How to sanitize SQL queries in C?

查看:73
本文介绍了如何在C中清理SQL查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
在C语言中防止SQL注入

Possible Duplicate:
Preventing SQL Injection in C

我知道PHP有一些内置函数可以帮助清理查询,但是C是否有类似的东西?

I know PHP has some built in functions that help to sanitize queries, but does C have anything like that?

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() 函数.

The MySQL C API has a mysql_real_escape_string() function.

这篇关于如何在C中清理SQL查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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