"mysql_escape_string() function is deprecated use mysql_real_escape_string() codeigniter" Code Answer

4

if you are using php 5.4 the function mysql_escape_string() is deprecated.so you need to do some changes in mysql driver file.go to systemdatabasedriversmysqlmysql_driver.php and find the escape_str function and replace the functions code with this code:

/**
  * 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;
 }

it may help you...

By Parama Sivam on January 11 2022

Answers related to “mysql_escape_string() function is deprecated use mysql_real_escape_string() codeigniter”

Only authorized users can answer the Search term. Please sign in first, or register a free account.