解决The mysql extension is deprecated and will be removed

Today the site is opened suddenly found error: "PHP Deprecated: mysql_connect (): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in".

Upon inquiry it was mysql_connect () The mysql extension is obsolete, it may be removed in the future. Recommended mysqli or pdo.

But why is it good before?

This is because different php versions, the new version will have this prompt.

There are three solutions.

method one

display_errors = On

Changed

display_errors = Off

Ban php error, but this is clearly unwise, because if what went wrong, we do not know.

Method Two

In php program, add the following code.

error_reporting(E_ALL ^ E_DEPRECATED);

But it not recommended, it is best to use three or mysql because it is too unsafe, too old.

Method Three

The change mysql mysqli, you may feel the need to change a lot, in fact, not much, just a general change mysql.class.php file on it.

For example, the

mysql_connect($server, $username, $password)

Changed

mysqli_connect($server, $username, $password,$database)

It can be.

Many places are the same, just the "mysql" changed to "mysqli" can be solved.

Guess you like

Origin www.cnblogs.com/xinyixuan/p/11527519.html