ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead.

September 24, 2013 4:14pm

Subscribe [1]
  • #1 / Sep 24, 2013 4:14pm

    JorgeRepossi

    1 posts

    I’ve this error on my server, and i don’t understand why,
    can someone help me
    A PHP Error was encountered

    Severity: 8192

    Message: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead.

    Filename: mysql/mysql_driver.php

    Line Number: 319

  • #2 / Sep 24, 2013 4:17pm

    JorgeRepossi

    1 posts

    Try this but not work for me

    /**
      * Escape String
      *
      * @param string
      * @param bool whether or not the string will be used in a LIKE condition
      * @return string
      */
     public function escape_str($str, $like = FALSE)
     {
      if (is_array($str))
      {
       foreach ($str as $key => $val)
          {
        $str[$key] = $this->escape_str($val, $like);
          }
    
          return $str;
         }
    
      $str = is_resource($this->conn_id) ? mysql_real_escape_string($str, $this->conn_id) : addslashes($str);
    
      // escape LIKE condition wildcards
      if ($like === TRUE)
      {
       return str_replace(array($this->_like_escape_chr, '%', '_'),
          array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'),
          $str);
      }
    
      return $str;
     }
    
     // --------------------------------------------------------------------
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases