开发者

How to sanitize SQL queries in C? [duplicate]

This question already has an answer here: Closed 11 years ago.

Possible Duplicate:

Preventing SQL Injection in 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!\开发者_Python百科n", mysql_error(connect));
  return;
}


The MySQL C API has a mysql_real_escape_string() function.


The C language and runtime have no such routine. Your particular database's particular client library might have something.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜