Hi ,
As it says in the title , how can I tell if the mysql_real_escape_string is working how it should without waiting to be hacked ?
Hi ,
As it says in the title , how can I tell if the mysql_real_escape_string is working how it should without waiting to be hacked ?
Check the values you get back from it.
Send it some text that it should escape, such as Ed O'Neil
(Which should come back as Ed O''Neil
or Ed O\'Neil
)
Create a unit test that sends it all characters it should escape and checks it output.
BUT: Why don't you simply use parameterized queries with PDO? Like:
$dbh = new PDO([...]);
$sth = $dbh->prepare("SELECT foo FROM bar WHERE baz=:baz");
$sth->execute(array(":baz" => $mybaz));
It is the safest way and thanks to PDO it's nearly as easy as in Perl.