addslashes and mysql_real_escape_string
2 отговора
180 прегледа
addslashes and mysql_real_escape_string
Каква е разликата м/у тези две функции и в кои ситуации е подходящо да използваме едната или другата и използването им достатъчно ли е за да ни предпази от sql injections.
Мерси предварително
Мерси предварително
РТФМ
mysql_real_escape_string
addslashes
от линковете
Намери десете разлики !
root@ro6avia#echo rm -rf * > /bin/seek_and_destroy
root@ro6avia#/bin/seek_and_destroy
addslashes
от линковете
В отговор на:
mysql_real_escape_string() calls MySQL's library function mysql_escape_string, which prepends backslashes to the following characters: NULL, \x00, \n, \r, \, ', " and \x1a.
addslashes Returns a string with backslashes before characters that need to be quoted in database queries etc. These characters are single quote ('), double quote ("), backslash (\) and NUL (the NULL byte).
Намери десете разлики !
root@ro6avia#echo rm -rf * > /bin/seek_and_destroy
root@ro6avia#/bin/seek_and_destroy
Редактирано от ro6avia на
Re: РТФМ
mysql_escape_string() does not escape % and _.
This function is identical to mysql_real_escape_string() except that mysql_real_escape_string() takes a connection handler and escapes the string according to the current character set. mysql_escape_string() does not take a connection argument and does not respect the current charset setting.
в момента се опитвам да си отговоря как точно се различава ескейпването ако се респектва текущия чарсет и ако не се. сигурно има някой чарсет дето това е важно, ма кой ли е той?
This function is identical to mysql_real_escape_string() except that mysql_real_escape_string() takes a connection handler and escapes the string according to the current character set. mysql_escape_string() does not take a connection argument and does not respect the current charset setting.
в момента се опитвам да си отговоря как точно се различава ескейпването ако се респектва текущия чарсет и ако не се. сигурно има някой чарсет дето това е важно, ма кой ли е той?