Page 1 of 1

Connecting from command line fails

Posted: Fri Oct 05, 2007 3:06 am
by Ree
Hello,

Here's a small test script I use to test connecting to an SQL Express server:

Code: Select all

$connection = @mssql_connect('.\SQLEXPRESS', 'sa', '123123123');
echo $connection === false ? 'Failure.' : 'Connected.';
The above script connects fine when running it via Apache, but it fails via CLI. I have no idea why this is happening. Any ideas you guys may have?

I'm on Vista x86, Apache 2.2, PHP 5.2.4, ntwdblib.dll is the right one.

Posted: Fri Oct 05, 2007 3:44 am
by Ree
I tracked the problem down to ntwdblib.dll. You must have the correct ntwdblib.dll not only in your system32 directory, but in the directory where your php.exe is present as well since CLI seems to check the latter one when using dlls.

Posted: Fri Oct 05, 2007 9:56 am
by feyd
Executables check their local directory first before looking elsewhere.