I am running codes that were running on php5 that support mysql_connect and I have migrated to another server that has php7.0. I realized that php7.0 does no longer support mysql_connect but it supports mysqli_connect. I don't want to go back to edit the codes and I don't want to go back to php5. I know that it's possible to install a patch that will support mysql_connect but I don't know how to do it. I am using ubuntu server 16.04.
Asked
Active
Viewed 2,629 times
0
-
I don't think any kind of `patch` is available there – Alive to die - Anant Mar 21 '18 at 07:52
-
2Why do you want such a huge step back? It is very good and reasonable that `mysql_connect` is no longer supported... Also please read this https://stackoverflow.com/help/how-to-ask – phrogg Mar 21 '18 at 08:01
-
1The reason is, we are moving to further development in java, we will no longer use php. However existing applications in php need to continue running and going back into codes to edit seems to be a wasted effort. I only need a temporal supporting environment of php7.0 running old codes. I know it is possible to use a patch that will support mysql_connect function but I don't know how to do it. – Innocento Mar 21 '18 at 08:46
-
Why don't you use PHP 5.6 longer? – Nico Haase Mar 21 '18 at 09:51
-
I want to benefit the new features and performance of php7. – Innocento Mar 21 '18 at 10:36
2 Answers
3
For these purposes, there is exactly this package: https://github.com/dshafik/php7-mysql-shim
to make it working without code modification, you can include it in auto_prepend_file
php.ini directive

mvorisek
- 3,290
- 2
- 18
- 53
-1
mysql_connect
is no longer supported in modern PHP versions for a reason.
I really recommend you to use PDOs
.
Here's a really great, detailed tutorial: https://phpdelusions.net/pdo

Christian Aichner
- 366
- 3
- 18
-
-
Yes mysql_connect was removed in new php versions. But there is a way of backward compatibility. – Innocento Mar 21 '18 at 08:54
-
But why? It is **outdated**. There is new technology you can use - like `PDOs` – Christian Aichner Mar 21 '18 at 08:56
-
1Thanks Christian, I understand your point. However, I am an infrastructure guy not a developper. I can see that PDOs requires to go into codes files and edit which I am avoiding. All I want is to see unmodified existing codes running on new environment since it's a temporal solution as developpers are busy moving to java. – Innocento Mar 21 '18 at 09:54