-5

I have error:

Fatal error: Uncaught Error: Call to undefined function mysql_escape_string() in /home/keramxd/domains/coaching.yotta.style/public_html/wp-content/themes/video/functions.php:60 Stack trace: #0 /home/keramxd/domains/coaching.yotta.style/public_html/wp-settings.php(424): include() #1 /home/keramxd/domains/coaching.yotta.style/public_html/wp-config.php(97): require_once('/home/keramxd/d...') #2 /home/keramxd/domains/coaching.yotta.style/public_html/wp-load.php(37): require_once('/home/keramxd/d...') #3 /home/keramxd/domains/coaching.yotta.style/public_html/wp-blog-header.php(13): require_once('/home/keramxd/d...') #4 /home/keramxd/domains/coaching.yotta.style/public_html/index.php(17): require('/home/keramxd/d...') #5 {main} thrown in /home/keramxd/domains/coaching.yotta.style/public_html/wp-content/themes/video/functions.php on line 60

My 60th line in functions.php:

if ( $wpdb->get_var('SELECT count(*) FROM `' . $wpdb->prefix . 'datalist` WHERE `url` = "'.mysql_escape_string( $_SERVER['REQUEST_URI'] ).'"') == '1' )
Sagar V
  • 12,158
  • 7
  • 41
  • 68
Marek
  • 1
  • 1
  • 1
    Possible duplicate of [mysql\_real\_escape\_string is undefined](https://stackoverflow.com/questions/13856639/mysql-real-escape-string-is-undefined) – HPierce Jun 17 '17 at 19:06
  • I changed PHP to 5.7 and I see website. Next errors: Deprecated: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead. in /home/keramxd/domains/coaching.yotta.style/public_html/wp-content/themes/video/functions.php on line 60 Warning: Cannot modify header information - headers already sent by (output started at /home/keramxd/domains/coaching.yotta.style/public_html/wp-content/themes/video/functions.php:60) in /home/keramxd/domains/coaching.yotta.style/public_html/wp-includes/pluggable.php on line 1210 – Marek Jun 17 '17 at 19:12
  • Line 1210 in pluggable.php: header("Location: $location", true, $status); – Marek Jun 17 '17 at 19:14

1 Answers1

-1

As of PHP 4.3.0, this function is deprecated, and it was removed in PHP 7.0.0

From comment by cale_b:

As this is WordPress, you should be using $wpdb->prepare() instead.

JohnCH
  • 365
  • 4
  • 13
  • I changed PHP to 5.7 and I see website. Next errors: Deprecated: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead. in /home/keramxd/domains/coaching.yotta.style/public_html/wp-co‌​ntent/themes/video/f‌​unctions.php on line 60 Warning: Cannot modify header information - headers already sent by (output started at /home/keramxd/domains/coaching.yotta.style/public_html/wp-co‌​ntent/themes/video/f‌​unctions.php:60) in /home/keramxd/domains/coaching.yotta.style/public_html/wp-in‌​cludes/pluggable.php on line 1210 – Marek Jun 17 '17 at 19:14
  • Line 1210 in pluggable.php: header("Location: $location", true, $status); – Marek Jun 17 '17 at 19:14
  • The first of those errors will be fixed by doing what I said and using mysqli_ instead of mysql_ – JohnCH Jun 17 '17 at 19:51
  • The second error there is unrelated to this issue, I suggest starting here: https://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php – JohnCH Jun 17 '17 at 20:02
  • 1
    You don't use `mysqli_escape_string` in WordPress. You use [$wpdb->prepare()](https://developer.wordpress.org/reference/classes/wpdb/prepare/) – random_user_name Jun 18 '17 at 17:34
  • Fair thanks, I did not know that, will edit the answer – JohnCH Jun 18 '17 at 17:35