Link to home
Start Free TrialLog in
Avatar of Geeth Janarthanan
Geeth Janarthanan

asked on

Call to undefined function mysql_connect() in php 7 ubuntu 16.04

Hi,

 mysql_connect()  not work in php version 7,Am manually install mysql in my pc,It's successfully install but still showing the errors,
How to run mysql_connect in php 7?Is it possible to run?
ASKER CERTIFIED SOLUTION
Avatar of Dan Craciun
Dan Craciun
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is correct. As Dan mentioned all mysql_*() calls change to mysqli_*() in PHP-7.0 + a few mysql_*() calls are completely dropped.

Most CMS systems, like WordPress handle all this for you, so if you're using a CMS upgrade to latest code base + likely you'll be done.

If you're running many lines of custom PHP, likely best to run phpcs across your code base to surface every problem.

https://github.com/wimg/PHPCompatibility provides installation instructions.

Then the command you'd used to find all problems will be something like this...

time nice -19 phpcs -s --parallel=$(cpus) --extensions="php,inc,lib" -d xdebug.show_exception_trace=0 --standard=PSR2 --runtime-set testVersion 7.1- /path-to-your-code > ~/phpcs-7.1-report.txt

Open in new window


Notice the innocuous "-" after 7.1 which means 7.1 + above, as 7.2 begins the complete PHP session replumbing that will take effect in PHP-8.0, so if you've written custom code, best incrementally ensure all your code works on 7.1 + 7.2, to prepare for 8.0 as session handling may require substantial recoding.

If you have .html files which contain PHP (shudder), then add html to your --extensions list.

The cpus script discovers number of total CPUs, so you can just hardcode this.
Avatar of Geeth Janarthanan
Geeth Janarthanan

ASKER

Solved