1

I know that this is deprecated and MSQLI and PDO are the alternatives. But I have developed a CMS in which I am still using MySQL. and it will take weeks to change all the quires. So is there any solution that I can use MYSQL with PHP 7 now? or it's impossible.

mysql_connect()
mysql_select_db()

etc

Dharman
  • 30,962
  • 25
  • 85
  • 135
NASIR KHAN
  • 13
  • 2
  • 9
  • Those functions are deprecated from PHP 5.5.0 and removed from php 7. You have to use the alternatives. – Mithun Adhikari Jan 08 '18 at 07:22
  • Even if there's a way to workaround, you should get to work and change this ASAP to `PDO`. [Here](https://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) you have alot of reasons to motivate you. – Yupik Jan 08 '18 at 07:24
  • write your own mysql_* with mysqli/pdo inside – Deadooshka Jan 08 '18 at 07:36

3 Answers3

2

If you like PDO and still want to use mysql_*-functions, try this: https://github.com/JaroslavHerber/php-mysql2pdo

It creates old mysql_*-functions for PHP7+ and uses a PDO-object in background. It was helpful for me to run plenty of old scripts on PHP7.

Jura Herber
  • 131
  • 8
0

if you still use those functions you should stop it right now, because, PHP 7 no longer support those functions, it only works until PHP 5.6. Otherwise, we should now use MySQLi or PDO.

0

https://github.com/e-sites/php-mysql-mysqli-wrapper wraps mysqli_* functions within their old mysql_* counterparts and it works like a charm. It requires the mysqli extension.

If you don't want to edit legacy applications to include()/require() it, you can use the auto_prepend_file ini directive to transparently require() it instead.

Cobra_Fast
  • 15,671
  • 8
  • 57
  • 102