2

I try to run a PHP script from the command line, but get the following error:

Call to undefined function mysql_connect()

However, the mysql module is loaded:

root /var/www/scripts # php -m | grep mysql
mysql
mysqli
pdo_mysql

I am on a Debian machine, so all modules are being loaded in their own .ini file:

root /var/www/scripts # php --ini
Configuration File (php.ini) Path: /etc/php5/cli
Loaded Configuration File:         /etc/php5/cli/php.ini
Scan for additional .ini files in: /etc/php5/cli/conf.d
Additional .ini files parsed:      /etc/php5/cli/conf.d/10-pdo.ini,
/etc/php5/cli/conf.d/20-apc.ini,
/etc/php5/cli/conf.d/20-gd.ini,
/etc/php5/cli/conf.d/20-mcrypt.ini,
/etc/php5/cli/conf.d/20-mysql.ini,
/etc/php5/cli/conf.d/20-mysqli.ini,
/etc/php5/cli/conf.d/20-pdo_mysql.ini,
/etc/php5/cli/conf.d/20-xmlrpc.ini

So even though the mysql module has been loaded, I still get said error when trying to call mysql_connect() in the PHP script.

Any ideas?

PS: Running the script via Apache works fine.

Matthias
  • 282
  • 3
  • 16

1 Answers1

0

A solution to this problem seems to be both easy and strange (?) alike:

php -c /etc/php5/cli/php.ini -nf script.php

Why do I have to specify the php.ini file on command line again, if the interpreter says it loads that ini file anyway, even when one does not specify it explicitly?

Matthias
  • 282
  • 3
  • 16