Connecting from command line fails

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

Connecting from command line fails

Post 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.
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Executables check their local directory first before looking elsewhere.
Post Reply