Page 1 of 1

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

Posted: Mon May 14, 2018 8:20 pm
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.

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

Posted: Mon May 14, 2018 8:28 pm
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

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

Posted: Mon May 14, 2018 8:30 pm
by nickk
Hi Shaan,

The PHP on my domain is 7.0

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

Posted: Mon May 14, 2018 8:35 pm
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

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

Posted: Mon May 14, 2018 8:37 pm
by nickk
Hi Shaan,

Downgrading PHP version worked.

Thanks for the quick fix.