开发者

How to sanitize SQL queries in C? [duplicate]

开发者 https://www.devze.com 2023-04-10 07:54 出处:网络
This question already has an answer here: Closed 11 years ago. Possible Duplicate: Preventing SQL Injection in C
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

精彩评论

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

关注公众号