SQL unescape string
#5

Quote:
Originally Posted by icra
Посмотреть сообщение
Nope,

mysql_real_escape_string puts a \ before ', "escaping it". In this way, the query won't recognize it as the end of the argument.

Example:

string = "Hit 'Em Up"

mysql_real_escape_string(string, result);

result = "Hit \'Em Up"

I think he needs displaying "result" as string, but if he's reading it from the query he'll have only "result". This means he haves to remove "\" character.

You can easily do a command like:

Код:
mysql_real_unescape_string(string[], result[]) {
   if(strcmp("\",result)) {
     // ... removes \ from the string.
   }
}
I'm not sure "\" character can be read from strcmp.
You need to use:

Код:
mysql_real_unescape_string(string[], result[]) {
   if(strcmp("\\",result)) {
     // ... replace "\\" with "\\\\"
   }
}
Reply


Messages In This Thread
SQL unescape string - by playadeseville - 16.05.2015, 02:21
Re: SQL unescape string - by Vince - 16.05.2015, 08:55
Re: SQL unescape string - by icra - 16.05.2015, 12:12
Re: SQL unescape string - by playadeseville - 16.05.2015, 12:17
Re: SQL unescape string - by rt-2 - 11.02.2017, 17:34

Forum Jump:


Users browsing this thread: 1 Guest(s)