codeIgniter use mysql_real_escape_string() instead.database connection issue

前端 未结 5 629
臣服心动
臣服心动 2021-01-06 04:52

I have code igniter installed on server with database I want to run the same db on my mac, I used MAMP and I copy the project folder inside htdocs, but I have this error wou

5条回答
  •  余生分开走
    2021-01-06 05:16

    also, to use the function mysqli_real_escape_str, you need the mysqli , to get it

    function get_mysqli() { 
    $db = (array)get_instance()->db;
    return mysqli_connect('localhost', $db['username'], $db['password'], $db['database']);}
    

    The above function returns a mysqli object such that you can use,

    $escaped = mysqli_real_escape_string(get_mysqli(),$string);
    

    It works well, not so important here though!

提交回复
热议问题