I am running a php page form the command line to update a mysql db once a php exec command has completed. This has been working OK.
However, I have just reinstalled my server and now the script is returning the following error when I run it on the command line:
Fatal error: Call to undefined function mysql_connect()
The script runs fine in the browser which means mysql is installed OK. How do I enable mysql in PHP to be run from the command line?
Many thanks.
First of all, you can use
from the command-line, to check which extensions are enabled.
If mysql is not in the list, it means it’s not enabled / loaded — which is probably the case, here.
Then, you’ll want to use
to check which
.inifile(s) is/are read by PHP.Once you’ve found out which
php.inifile is used, you’ll have to edit it, and add something like this :To load the
mysqlextension.Depending on your distribution, the might be a
.inifile per extension (Ubuntu does that, for instance).If that’s the case, you could also create a new
.inifile (mysql.inifor instance) next to the other ones, and put the two lines I posted into that new file.