简体   繁体   中英

Codeigniter Deprecated: mysql_real_escape_string():

Got below error while using 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

use mysqli_real_escape_string();

and replace mysql to mysqli in every functions.

Go to application => config => database.php and change from

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

to

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

Note It is recommended to use query builder class for queries.

You should use PDO in codeigniter to solve all problem related to mysql and mysqli ..

see how to use PDO in CI if you are using CI 3 then http://www.codeigniter.com/user_guide/database/configuration.html

and if you are using CI 2.x How to use pdo in codeigniter?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM