unsigned int mysql_escape_string(char *to, const char *from, unsigned int length)
unsigned int mysql_escape_string(char *to, const char *from)
| |
Encodes a string so that it is safe to insert it into a MySQL table.
The first argument is the receiving string, which must be at least
one character greater than twice the length of the second argument,
the original string. (That is, to >= from*2+1.) If a third
argument is present, only that many bytes are copied from the
originating string before encoding it. The function returns the
number of bytes in the encoded string, not including the terminating
null character.
Example
char name[15] = "Bob Marley's";
char enc_name[31];
mysql_escape_string(enc_name, name);
/* enc_name will now contain "Bob Marley\'s" (the single quote is escaped).