Php:codeigniter mysql_real_escape_string Warning

Source: Internet
Author: User
Tags codeigniter

Version CodeIgniter 3 PHP 5.4

Thanks to the Almighty StackOverflow.

To modify the source code of CodeIgniter.

./system/database/drivers/mysql/mysql_driver.php

/** * Escape String * * @access public * @param String * @param bool whether or not the String would be used-a like condition * @return string*/    functionESCAPE_STR ($str,$like=FALSE)    {        if(Is_array($str))        {            foreach($str  as $key=$val)               {                $str[$key] =$this->ESCAPE_STR ($val,$like); }               return $str; }        if(function_exists(' mysql_real_escape_string ') andIs_resource($this-conn_id)) {            $str=mysql_real_escape_string($str,$this-conn_id); }                ElseIf(function_exists(' mysql_real_escape_string '))        {            if(Is_object($this-conn_id)) {                            $str=mysql_real_escape_string($str,$this-conn_id); } Else {                            $str=addslashes($str); }        }ElseIf(function_exists(' mysql_escape_string '))        {            $str=mysql_escape_string($str); }        Else        {            $str=addslashes($str); }        //escape like condition wildcards        if($like===TRUE)        {            $str=Str_replace(Array(‘%‘, ‘_‘),Array(‘\\%‘, ‘\\_‘),$str); }        return $str; }

Italic underlined is the modified part.

Reference: https://stackoverflow.com/questions/33995279/ codeigniter-showing-error-mysql-real-escape-string-expects-parameter-2-to-be

Php:codeigniter mysql_real_escape_string Warning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.