san_merah Posted November 12, 2015 Share Posted November 12, 2015 I just tried to move a latest version of presta from a server with php 5.3 to one with php 5.5 and getting this on new server: Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/shopformbd/public_html/classes/db/MySQL.php on line 37 Warning: Cannot modify header information - headers already sent by (output started at /home/shopformbd/public_html/classes/db/MySQL.php:37) in /home/shopformbd/public_html/classes/shop/Shop.php on line 422 Warning: Cannot modify header information - headers already sent by (output started at /home/shopformbd/public_html/classes/db/MySQL.php:37) in /home/shopformbd/public_html/classes/shop/Shop.php on line 423 My hosting company says: This warning is given because your code is using a deprecated function and it will soon stop being supported by PHP.The warning given mentions your site code specifically/home/shopformbd/public_html/classes/db/MySQL.php line 37The entire ext/mysql PHP extension, which provides all functions named with the prefix mysql_, is officially deprecated as of PHP v5.5.0 and will be removed in the future.It was originally introduced in PHP v2.0 (November 1997) for MySQL v3.20, and no new features have been added since 2006. Coupled with the lack of new features are difficulties in maintaining such old code amidst complex security vulnerabilities.As the error message suggests, there are two other MySQL extensions that you can consider: MySQLi and PDO_MySQL, either of which can be used instead of ext/mysql. Both have been in PHP core since v5.0, so if you're using a version that is throwing these deprecation errors then you can almost certainly just start using them right away—i.e. without any installation effort.They differ slightly, but offer a number of advantages over the old extension including API support for transactions, stored procedures and prepared statements (thereby providing the best way to defeat SQL injection attacks). PHP developer Ulf Wendel has written a thorough comparison of the features.Hashphp.org has an excellent tutorial on migrating from ext/mysql to PDO.http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers How to fix it? Link to comment Share on other sites More sharing options...
tuk66 Posted November 13, 2015 Share Posted November 13, 2015 Your hosting company is right. Even so, its php.ini file should have set ~E_DEPRECATED for the error_reporting parameter. You can also try to set _PS_MODE_DEV_ to false in your defines.inc.php. Link to comment Share on other sites More sharing options...
bellini13 Posted November 13, 2015 Share Posted November 13, 2015 Prestashop will check if either PDO or MySQLI extensions are installed and enabled and use them. Apparently these are not enabled on your server, so Prestashop reverts to using the deprecated one public static function getClass() { $class = 'MySQL'; if (PHP_VERSION_ID >= 50200 && extension_loaded('pdo_mysql')) { $class = 'DbPDO'; } elseif (extension_loaded('mysqli')) { $class = 'DbMySQLi'; } return $class; } Link to comment Share on other sites More sharing options...
san_merah Posted November 14, 2015 Author Share Posted November 14, 2015 Thanks, we rebuilt apache and changed php back to 5.3. Later I found out where to enable Mysqli so at some point we will enable all required plugins and set php to 5.5. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now