Question:
PHP: Is it safe to call mysql_real_escape_string twice on the same string?
nute
2008-02-20 16:50:40 UTC
In php:
$input =
"blabla/'!@#$%^&*&*())_+";
$input =
mysql_real_escape_string ($input);
$input =
mysql_real_escape_string ($input);
$input =
mysql_real_escape_string ($input);

Is the function mysql_real_escape_string smart enough not to escape the escaped characters again?
Or is it important to do it just once?
Thanks.
Three answers:
General Cucombre
2008-02-20 17:01:23 UTC
It is not unsafe to call mysql_escape_string() or mysql_real_escape_string() multiple times for security purposes, however the function is not "smart enough" to prevent repeated escaping - if you do so, it will damage your data - i.e. you'll end up with multiple backslashes - just see for yourself - this is what comes out of your test:



'blabla\\\\\\\'!@#$%^&*&*())_+'



So yes, it is important to call it only once.



There is a technical term for similar type of phenomenon, by the way - when there are too many slashes - LTS (Leaning Toothpick Syndrome):

http://en.wikipedia.org/wiki/Leaning_toothpick_syndrome :)
lizardy
2016-12-30 18:32:38 UTC
The beginning place of the time era "G-string" is imprecise. The time era is first attested in writings via human beings interior the previous due 1800s describing the loincloth of Philippines natives. interior the "Philippines Islands" get admission to interior the 1911 version of the Encyclopædia Britannica, the time era "geestring" is used. Others say the time era is derived from the G-string on a musical device, even nonetheless that's an abbreviation of "groin-string". The beginning place of the be conscious "thong" is from the previous English thwong,a versatile leather-based twine. there are a number of intermediate varieties between complete rear coverage and a string rear. like the tanga, the g-sting is basically a backside protecting that covers the pubis and leaves the buttocks bared; The time era g-string is frequently used while the vertical strap interior the rear of a thong is not any wider than a string. different comparable varieties contain the brazilian, rio, and t-back. The naming of the intermediate cuts is arguable, and diverse distributors use the phrases fairly interchangeably. Wikipedia
?
2016-10-16 12:20:34 UTC
Php Mysql_escape_string


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...