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.
精彩评论