If you are getting below error on your website then it for sure that your website was developed through deprecated mysql extension and php version (either your website’s source code is very old and never updated or recently your website is developed through outdated scripts and extensions).
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/username/public_html/admin/func.php on line 4
MySQL extension is deprecated and will not be available in future PHP versions. It is highly recommended to use the MySQLi extension. Basically, MySQL is the old database driver, and MySQLi is the Improved driver. here “i” stands for “improved” so it is improved MySQL.
MySQL and MySQLi are PHP database extensions implemented by using PHP extension framework. PHP database extensions are used to write PHP code for accessing the database. They expose database API to provide interfaces to use database functions.
Reasons why you should use MySQLi extension instead of the MySQL extension are many:
- MySQLi gives you prepared statements – a safer way of sending data to MySQL and protecting you from SQL injection. This alone should be enough for always choosing MySQLi over MySQL.
- MySQLi enables most of the MySQL features.
- MySQLi is object orientated.
- MySQLi supports prepared statements, transactions and multiple statements.
- The old MySQL extension is deprecated as of PHP 5.5.0
And there are also other benefits as well. But mainly, you should focus on security and stability – and MySQLi gives you just that.
MySQLi can boost your site’s speed and performance, you’ll also gain increased security. Newer versions of PHP have more frequent security updates to help protect your site against unwanted hacks or malware. If you are still using old MySQL PHP versions then you may experience a brief disruption in service. If you wish to avoid any disruption please ensure, you have updated the PHP version on your sites.