I got a Wordpress system running on PHP 7.0.11 using Wordpress. A plugin I want to use does not work and checking the logs does result in
PHP Fatal error: Uncaught Error: Call to undefined function mysql_real_escape_string() in…
Looking for this error message I have found that the mysql_real_escape_string()
extension was deprecated.
How can I convert this statement to work in PHP 7 and above?
$ids = mysql_real_escape_string( $ids );
$result = $wpdb->query( "DELETE FROM $table_name WHERE id IN( $ids )" );
I have found this in the Wordpress docs: wpdb::_real_escape()
you can use wordpress native function
wpdb::_real_escape( string $string )
or
$query = $wpdb->prepare(
"SELECT post_title from $wpdb->posts
WHERE post_title LIKE %s",
"%" . $myTitle . "%"
);
find more here
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