PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() in

Discussions related with hosting control panels used, which include cPanel, Plesk, Directadmin etc..
Post Reply
nickk
Posts: 0
Joined: Wed Oct 26, 2016 9:38 am

PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() in

Post by nickk »

Hi,

My site is showing blank screen. I checked error log and found below error.

#1 /home/example/public_html/index.php(2): require_once('/home/example/p...')
#2 {main}
thrown in /home/example/public_html/php/tools.php on line 34
PHP Warning: Cannot modify header information - headers already sent by (output started at /home/example/public_html/index.php:1) in /home/example/public_html/php/pagetools.php on line 2
PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /home/example/public_html/php/tools.php:38


Please help me to fix this.



shaan
Posts: 0
Joined: Sat Apr 14, 2018 4:21 pm

Re: PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() in

Post by shaan »

Hi Nick,

From the error you have provided, its seems like the PHP version on your domain is not compatible with the site code/function.

Can you please let me know the site PHP version by adding the below file to public_html folder or asking to your host.

> Create phpinfo.php file in /home/user/public_html folder

> Add the below code to phpinfo.php file

<?php phpinfo(); ?>

> save and close the file.

In browser access the url domain.com/phpinfo.php which show the PHP version on your domain.


Shaan N
Linux Support Engineer.
Nixtree Solutions
Managed Full Server Backups
https://www.nixtree.com/managed-backups.php
Follow us on : https://twitter.com/nixtree



nickk
Posts: 0
Joined: Wed Oct 26, 2016 9:38 am

Re: PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() in

Post by nickk »

Hi Shaan,

The PHP on my domain is 7.0



shaan
Posts: 0
Joined: Sat Apr 14, 2018 4:21 pm

Re: PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() in

Post by shaan »

Hi Nickk,

So it is perfectly clear now.

mysql_* functions were removed as of PHP 7.

It is not recommended to use the old mysql extension for new development, as it was deprecated in PHP 5.5.0 and was removed in PHP 7. It is recommended to use either the MySQLi or PDO extensions.

You can seek the help of a developer to rewrite the site code to make it compatible. Or one of the easiest ways to fix the error is downgrading the PHP version.

Please try downgrading your PHP version from 7.0 to lower version and check the site.


Shaan N
Linux Support Engineer.
Nixtree Solutions
Managed Full Server Backups
https://www.nixtree.com/managed-backups.php
Follow us on : https://twitter.com/nixtree



nickk
Posts: 0
Joined: Wed Oct 26, 2016 9:38 am

Re: PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() in

Post by nickk »

Hi Shaan,

Downgrading PHP version worked.

Thanks for the quick fix.



Post Reply