Hi.
I want to escape any special characters in the input field before inserting the data into mysql tables in C++.
Here is how I am using this function
// Escaping special characters in the Subject field
char * S = new char[strlen(m_headerSubject.c_str())*3 +1];
mysql_real_escape_string(conn, S, m_headerSubject.c_str(), m_headerSubject.length());
m_headerSubject = m_headerSubject.assign(S);
In most of the cases the string is properly escaped and everything works fine but I have observed in some cases my prog. is executed till the point where I am calling this function and then breaks, suggesting that there is some wrong in using this function.
If I remove the function, the prog. works fine 100% of the time, though the strings requiring escape sequence are not entered into the database.
Not getting any errors, the program just exits out at the point where I am calling this function, in the debug routine also I can't see any errors.
Appreciate any help.
Thanks.