if (phpversion() >= '4.3.0'){
$string = mysqli_real_escape_string($string);
}else{
$string = mysqli_escape_string($string);
}
All the documentation for mysqli_real_escape_string
seems to indicate this is a valid bit of code, but I don't understand why I get this error:
mysqli_real_escape_string() expects exactly 2 parameters, 1 given
The mysqli_real_escape_string() function is an inbuilt function in PHP which is used to escape all special characters for use in an SQL query. It is used before inserting a string in a database, as it removes any special characters that may interfere with the query operations.
You should use real_escape_string on any parameter you're mixing as a string literal into the sql statement. And only on those string literal values.
This extension was deprecated in PHP 5.5. 0, and it was removed in PHP 7.0.
Documentation says it needs two parameters:
string mysqli_real_escape_string ( mysqli $link , string $escapestr )
The first one is a link for a mysqli instance, the second one is the string to escape.
Following is the proper format to use it :
string mysqli_real_escape_string ( mysqli $link , string $escapestr )
first parameter is mysql connection link identifier, and second is string For more details, you can visit this link : http://in2.php.net/manual/en/mysqli.real-escape-string.php.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With