I've installed various PHP packages to be able to use PHP with Apache but also in the commandline. From both I need to be able to connect to MySQL databases. Pretty simple right? That's what I thought but with php-cli I receive following error:
Fatal error: Call to undefined function mysql_pconnect()
I have tried starting from scratch by removing all depending packages and configuration like this:
sudo apt-get --purge remove php5 libapache2-mod-php5 php5-cli php5-mysql
Then I've run following command to install the packages:
sudo apt-get install php5 libapache2-mod-php5 php5-cli php5-mysql
Then I've found out which php.ini the cli uses like that:
php -r "phpinfo();" | grep php.ini
Which gives me this:
Configuration File (php.ini) Path => /etc/php5/cli/php.ini
Then i've uncommented 'mysql.so' in the extensions section but when i do and run following command it says:
PHP Warning: Module 'mysql' already loaded in Unknown on line 0
So for some reason he thinks it is already loaded, but with or without the 'mysql.so' enabled the php cli does not find the 'mysql_pconnect' function.
I know there's a sections to enable persistent connections, it on by default and the standard function 'mysql_connect' is also not available.
What am I missing? Thanks!
UPDATE:
As suggested by Bart S. 'php -r "phpinfo();" | grep mysql':
MYSQL_SOCKET => /var/run/mysqld/mysqld.sock MYSQL_INCLUDE => -I/usr/include/mysql MYSQL_LIBS => -L/usr/lib -lmysqlclient mysql.allow_persistent => On => On ... and more
From Jaka JanĨar. 'php -v' shows:
PHP 5.1.2 (cli) (built: Feb 11 2009 19:55:22)
And from php interactive mode 'php -r 'var_dump(extension_loaded("mysql"));' gives nothing!
-
php -i | grep mysqlThe first line should contain:
Configure Command => '../configure' ... '--with-mysql=shared,/usr'Also check
grep extension_dir /etc/php5/cli/php.iniShould be something like:
extension_dir = /usr/lib/php5/extensionsThen check permissions of/usr/lib/php5/extensions/mysql.soand if it's properly linked:ldd /usr/lib/php5/extensions/mysql.so -
Does pconnect in cli mode make sense? maybe this is "working as intended".
Note: Note, that these kind of links only work if you are using a module version of PHP. See the Persistent Database Connections section for more information.
http://de2.php.net/mysql_pconnect
Sander Versluys : mysql_connect doesn't work either. And i would think mysql_pconnect should work, but idd it does not make sense, i'm using the sphyder search engine cli scripts. and i'm using it exactly like docs tell me.
0 comments:
Post a Comment