1

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

3 Answers 3

6

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.

Sign up to request clarification or add additional context in comments.

Comments

5

use mysqli_real_escape_string();

and replace mysql to mysqli in every functions.

4 Comments

A PHP Error was encountered Severity: Warning Message: mysqli_real_escape_string() expects exactly 2 parameters, 1 given Filename: models/common_model.php Line Number: 21 Backtrace:
yes, first parameter should be link returned by ` mysqli_connect();`
sir in codigniter we add database in application/config/database.php so would their b link of database.....
yes, sorry, i didn't notice that, you have to change core file of CI where actual mysql_connect() is used, instead you can use PDO. just my another answer.
4

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?

1 Comment

Error Was Encountered Invalid DB driver

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.