Created
October 19, 2014 16:11
-
-
Save andreyserdjuk/71a60eca241178e7e3cd to your computer and use it in GitHub Desktop.
mysql_real_escape_string alternative (analogue)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// mysql_real_escape_string requires an active mysql connection | |
function mysqlPrepareStr($str) { | |
return "'". str_replace( | |
array( '\\', "\0", "\n", "\r", "'", '"', "\x1a" ), | |
array( '\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z' ), | |
$str ) . "'"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment