There was a problem loading the comments.

My PHP script gives the error 'Call to undefined function: mysql_connect()'

Support Portal  »  Knowledgebase  »  Viewing Article

  Print
This can be caused by two things.

Using PHP 7 or newer

The MySQL connector is now out-of-date and has been replaced by the MySQLi connector in PHP.All mysql_*() functions were deprecated in PHP 5.6, and removed from PHP 7.

It is recommended to replace mysql_*() functions with mysqli_*() functions regardless of which PHP version you use, but if this isn't feasible, you would need to set your site's PHP version to 5.6 in order for the older mysql_*() functions to work.

You can set the PHP version of your site in your hosting control panel, which you can access via http://www.ecowebhosting.co.uk/cp/managehosting.

Incorrect .user.ini directive

If you're using an older PHP version and experience this issue, the reason is likely to be that the extension_dir directive is specified in a custom .user.ini file. If you are getting this error and you have a custom .user.ini that has the extension_dir directive in it then please remove this line which should resolve the problem.

Using a .user.ini found on other webservers or examples given on PHP-related websites will likely cause problems such as this.

If this does not resolve the issue, you should contact whoever supplied the script that you are attempting to run as this may suggest a coding issue.

Share via
Did you find this article useful?  

Related Articles

© Eco Web Hosting