Inherited site

I’ve recently inherited a site which has been transferred into my hosting account with a view that i update and maintain as it, however upon completion of the transfer clicking various links on the homepage returns the following errors:

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /var/sites/h/happyhensuk.com/public_html/includes/classes/class.phpmailer.php on line 19

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /var/sites/h/happyhensuk.com/public_html/includes/classes/class.DBMySql.php on line 21

Warning: mysql_connect(): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2) in /var/sites/h/happyhensuk.com/public_html/includes/classes/class.DBMySql.php on line 21
Unable to connect to database server!

I’ve tried changing the deprecated extensions but that gives another error

The first error can probably be fixed by updating the version of phpmailer.

The second error can be fixed by converting the code to use the php PDO extension. While it may seem like updating older mysql_ code to use the mysqli_ extension is a good solution, it isn’t. Using the php PDO extension, using prepared queries, and using exceptions to handle database statement errors, results in the simplest sql syntax and the least amount of php code, meaning you can probably eliminate a lot of the existing code, rather than to spend time trying to convert it.

The last error is because no connection to a local database server could be made. If the DBMySql class code was well written, it should log the actual connection error information, otherwise you will need to modify it with some error handling so that it does tell you why the connection is failing. Some common problems would include - 1) the connection credentials are incorrect, 2) the database user hasn’t been granted permission to access a database, and 3) the database server is not on the same server with the web server.

I've tried changing the deprecated extensions but that gives another error

^^^ If you want specific help with any code or an error, you will need to post the relevant code and the error message.

Yes, without code, we can not help you. Here is a beginner’s tutorial on MySQLi commands. It might help you understand the minor differences from the older MySQL commands. Good luck!
https://www.w3schools.com/php/php_ref_mysqli.asp

Sponsor our Newsletter | Privacy Policy | Terms of Service