Question

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

Was it helpful?

Solution

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?

OTHER TIPS

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

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top