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' )

protected by Community Nov 29 '17 at 10:13

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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