已弃用 Codeigniter:mysql_real_escape_string():

Codeigniter Deprecated: mysql_real_escape_string():

使用 codigniter 3.0 时出现以下错误

FYI using PHP Version 5.5.12,Apache Version Apache/2.4.9 (Win64) PHP/5.5.12

A PHP Error was encountered

Severity: 8192

Message: mysql_real_escape_string(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead

Filename: models/common_model.php

Line Number: 21

Backtrace:

File: C:\wamp\www\Codeigniter\application\models\common_model.php Line: 21 Function: mysql_real_escape_string

使用mysqli_real_escape_string();

并在每个函数中将 mysql 替换为 mysqli

转到 application => config => database.php 并从

更改
$db['default']['dbdriver'] = 'mysql';

$db['default']['dbdriver'] = 'mysqli';

注意建议使用query builder class查询

您应该在 codeigniter 中使用 PDO 来解决与 mysqlmysqli..

相关的所有问题

查看如何在 CI 中使用 PDO 如果您使用 CI 3 那么 http://www.codeigniter.com/user_guide/database/configuration.html

如果您使用的是 CI 2.x How to use pdo in codeigniter?