tags:

views:

421

answers:

3

Hi,

I have installed XAMPP on a Windows XP Machine. PHP scripts are working fine through the browser.

Initially, PHP.exe (CLI) was failing with error - can't load php_pgsql.dll

I disabled extension=php_pgsql.dll in the php.ini file and PHP.exe stopped to fail.

However, even now I am not able to run a PHP script from the CLI even though the same script runs fine through the browser.

The script fails at mysqli_connect() with error - Can't connect to MySQL server on '127.0.0.1'

Has somebody else faced the same problem?

Kshitij

A: 

Is the path to your mysql DLLs in your command session's PATH environment variable? You probably need to add \pathtomysql\bin to your path. On my machine it is:

C:\Program Files\MySQL\MySQL Server 5.0\bin
jmucchiello
Added the path to the environment. Still not working.
+1  A: 

How many php.ini have you got? It's likely the CLI version has a different php.ini than the web version.

Vinko Vrsalovic
I have changed both php.ini as well as php5.ini
A: 

Did you start the MySQL service via the XAMPP Control panel and it kept beeing marked as "Running" in both test cases?
Did you test the webserver version by requesting something like http://localhost/... or http://127.0.0.1/... and did you run the php.exe -f something.php test on the same machine?

VolkerK
It finally worked :) The CLI is able to run when I use the complete IP of the server. However, the webserver is able to run the script with either 'localhost' or '127.0.0.1'. Thanks for the help.