0

This is some strange problem I'm facing, my local machine runs php 5.6.3 while live server is running php 5.4. We recently updated our app from codeigniter 2.* to codeingiter 3.0, now while running on live server we came to know about this brand new issue (older one and still not working smtp)

A PHP Error was encountered

Severity: 8192

Message: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead.

Filename: mysql/mysql_driver.php

Line Number: 319

Now after doing some googling, I found that top solution might be for ci 2.* doesn't work as codeigniter's mysql_drivers.php file is already using mysql_real_escape_string(). One answer is suggesting that I should check database.php file. If my default connection is mysql instead of mysqli which is mysqli, now I've no way to find out what is going wrong or what I'm missing.

1
  • Consider using prepared statements and you don't need to use mysql_escape_string() or mysql_real_escape_string() Commented Jul 19, 2015 at 12:56

2 Answers 2

1

PHP mysql driver is deprecated since 5.5. See http://php.net/manual/en/intro.mysql.php

So you better not use it. Use mysqli.

Line 319 on mysql/mysql_driver.php: https://github.com/bcit-ci/CodeIgniter/blob/3fe79499c5bedb5b3bc4281821776f031f73674e/system/database/drivers/mysql/mysql_driver.php#L319

There is no mysql_escape_string(). It seems you didn't update to 3.0 correctly.

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

2 Comments

yes even i saw, but i don't know why it is throwing this warning ? I updated CI thoroughly following the blog
What do you mean? Your mysql/mysql_driver.php code is different from 3.0's code, isn't it? 3.0's code line 319 is comment ` * Rollback Transaction`.
0

And problem is you are conflicting MySQL and MySQLi

To solve your problem use mysqli_real_escape_string()

More Details to Your Knowledge

About mysql_escape_string()

Warning:
This function was deprecated in PHP 4.3.0, and will be removed in the future, along with the entirety of the original MySQL extension. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide and related FAQ for more information. Alternatives to this function include:
mysqli_escape_string()
PDO::quote()

About mysql_real_escape_string()

Warning:
This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide and related FAQ for more information. Alternatives to this function include:
mysqli_real_escape_string()
PDO::quote()

Comments

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.