0

I have legacy software which cannot be upgraded and I require PHP 5.3 for depreciated functions like mysql_connect() and session_register(). Running Debian 9.5 and lighttpd (can use Apache/nginx if necessary)

PHP doesn't seem to have the mysql extension installed: Fatal error: Call to undefined function mysql_connect()

I downloaded and compiled PHP 5.3 and here's the output of phpinfo().

I have php5.6-mysql and php-mysql installed but perhaps it's not compatible or not enabled for 5.3? The installed mysql version is Ver 15.1 MariaDB

I'm at a loss on what else to try or what I can do, any suggestions would be appreciated

dukevin
  • 22,384
  • 36
  • 82
  • 111
  • 2
    If you have the extensions for 5.6, why not use PHP 5.6 and turn off deprecation warnings? (even though I would recommend rewriting the application to use the superior PDO or MySQLi instead, but if it's not an option...) – M. Eriksson Sep 26 '18 at 11:43
  • 1
    Extensions for php5.6 will not work with PHP5.3 – RiggsFolly Sep 26 '18 at 11:45
  • @MagnusEriksson 5.6 doesn't allow for session_register() unfortunately, that was my first venture (mysql worked then). I don't own the source and not authorized to modify it. – dukevin Sep 26 '18 at 11:46
  • 2
    Did you follow the manual for compiling with mysql…? http://php.net/manual/en/mysql.installation.php – deceze Sep 26 '18 at 11:48
  • You can also try and run it through Docker. – M. Eriksson Sep 26 '18 at 11:50
  • @deceze Thanks for that suggestion, I didn't know that I needed to compile with those flags. It sort of works now, thanks! The other issue is now it says: `Warning: mysql_connect() [function.mysql-connect]: [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock). ` – dukevin Sep 26 '18 at 12:21
  • @dukevin this is a different question, so you should not ask it in a comment. Also, you could have searched for the error message, which would have yielded this question on SO: https://stackoverflow.com/questions/4219970/warning-mysql-connect-2002-no-such-file-or-directory-trying-to-connect-vi Also, pls note that a program written for an old version of MySQL may be in for some nasty surprises if you use a modern version of mariadb. Mariadb was indeed a fork from MySQL, but it has deviated from it . Code that used to run in an old MySQL may not run in mariadb or may produce different results. – Shadow Sep 26 '18 at 14:23
  • `I don't own the source and not authorized to modify it.` - tell the owner that your price just tripled – Martin Sep 27 '18 at 10:47

2 Answers2

0

Try to download the php5-mysql package and include it in the loaded extensions

Here is a link to it in the debian repo... https://packages.debian.org/es/sid/php5-mysql

nrip
  • 131
  • 4
  • How do I include it in the loaded extensions? I already do have php5.6-mysql on my system (assuming that is what you linked) and it worked when I had php5.6 but I require 5.3. Not sure if it matters – dukevin Sep 26 '18 at 11:49
  • sorry discard my answer. I was talking about adding the extension in case it was missing. For 5.3, , the flags for mysql to be included must be added when compiling as dukevin has mentioned above. ./configure --with-mysql=mysqlnd – nrip Sep 27 '18 at 12:15
0

The answer taken from @deceze was that php 5.3 does not come packaged with mysql and must be specified at compile time. ./configure --with-mysql=mysqlnd

See this for your specific installation: http://php.net/manual/en/mysql.installation.php

dukevin
  • 22,384
  • 36
  • 82
  • 111