0

I don't know coding. I was just trying to install a theme and this error keeps showing up on both the 'visit site' and the admin panel itself.

Deprecated: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead. in /home/designe6/public_html/wp-content/themes/qoon-child/functions.php on line 60

Deprecated: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead. in /home/designe6/public_html/wp-content/themes/qoon-creative-wordpress-portfolio-theme/functions.php on line 60

And to show you what line 60 is in the child theme:

if ( $wpdb->get_var('SELECT count(*) FROM `' . $wpdb->prefix . 'datalist` WHERE `url` = "'.mysql_escape_string( $_SERVER['REQUEST_URI'] ).'"') == '1' )

And the line 60 for the main theme is:

if ( $wpdb->get_var('SELECT count(*) FROM `' . $wpdb->prefix . 'datalist` WHERE `url` = "'.mysql_escape_string( $_SERVER['REQUEST_URI'] ).'"') == '1' )

Please help I don't know how to fix. Can anybody volunteer to help me convert my php files to the most compatible mysqli or PDO?

2

mysql_real_escape_string() extension was deprecated in PHP 5.5.0. So you can try below code:

if ( $wpdb->get_var( $wpdb->prepare( "SELECT count(*) FROM {$wpdb->prefix}datalist WHERE `url` = %s", $_SERVER['REQUEST_URI'] ) == '1' ) )

You can get more here.

-1

Use esc_sql() instead of mysql_escape_string.

Update :

if ( $wpdb->get_var('SELECT count(*) FROM `' . $wpdb->prefix . 'datalist` WHERE `url` = "'.esc_sql( $_SERVER['REQUEST_URI'] ).'"') == '1' )

Not the answer you're looking for? Browse other questions tagged or ask your own question.