(no title)
postfuturist | 12 years ago
$id = mysql_real_escape_string($_GET['id']);
$res = mysql_query("SELECT foo FROM bar WHERE id='$id'");
That may be ugly, but it's bulletproof regarding injection.postfuturist | 12 years ago
$id = mysql_real_escape_string($_GET['id']);
$res = mysql_query("SELECT foo FROM bar WHERE id='$id'");
That may be ugly, but it's bulletproof regarding injection.
thangalin|12 years ago
http://codereview.stackexchange.com/questions/26507/generic-...
hcarvalhoalves|12 years ago
Joeri|12 years ago
PHP has some of the insanest defaults due to its C heritage. String functions deal with bytes not characters, so cannot be used safely with utf8 without setting the mbstring.func_overload setting to replace them with unicode-aware versions (except for str_pad, which always deals in bytes). Sort() defaults to binary sorting, and cannot be tricked in any way to sort utf8 in dictionary order if you're running your server on windows (and even on linux it requires an extra parameter on every call). Natsort(), which is supposed to sort like a human would, cannot be made to sort in dictionary order at all. The proper way to sort is by using the Collator class, which is not referenced from the sort() documentation, didn't exist before PHP 5.3, and is in the optional intl extension which is usually disabled by default.
Still better than mysql though, which has a very unique interpretation of unicode collation.
brokenparser|12 years ago
The search goes like this: https://github.com/search?q=mysql_query+%22SET+NAMES%22+mysq...
ecaron|12 years ago
EdiX|12 years ago
noinput|12 years ago
unknown|12 years ago
[deleted]
serge2k|12 years ago
krapp|12 years ago
I found this interesting, though, regarding specifically SQL injection when mysql_real_escape_string is used: http://stackoverflow.com/questions/5741187/sql-injection-tha...
basically the argument appears to boil down to mixed character sets causing escaping not to act as predicted. I can't speak to the validity of it though.
bluetooth|12 years ago
siddboots|12 years ago
Nodex|12 years ago
[deleted]