Thread: using mysql_real_escape_string()

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    3

    using mysql_real_escape_string()

    Hi,
    I want to escape any special characters in the input field before inserting the data into mysql tables in C++.
    I know we can use
    Code:
    mysql_real_escape_string()
    function, however I am unsure how to use it, can anybody point me to any examples on this, or write me an example regarding what parameters this function takes and how to use this function.
    Thanks,
    Tewari

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    http://dev.mysql.com/doc/mysql/en/my...pe-string.html

    Code:
    const char *from = "What's this";
    char *to = new char[(strlen(from) * 2) + 1];
    mysql_real_escape_string(&mysql, to, from, strlen(from));

Popular pages Recent additions subscribe to a feed