By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,831 Members | 2,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,831 IT Pros & Developers. It's quick & easy.

mssql_connect() Problems

P: n/a
I have a server with Windows 2000, PHP 5, IIS and SQL Server 2000
running. Individually, each works great. When trying to bring PHP and
MSSQL together, though, I'm tearing my hair out...it just will not
connect. Not even an error message.

Consider the code:

<?php
$server = "localhost"; // have also tried "[servername]", "localhost:
1433" and "[servername]:1433"
$username = "administrator"; // Windows username
$password = "[password]";
if (!mssql_connect($server, $username, $password))
echo "Could not connect.<p>";
?>

When thinking about all the things I've tried based on the wisdom of
the Internet, I'm stunned it still doesn't work:
* Upgraded the ntwdblib.dll file that PHP uses to 8.0.194, the latest
version
* Configured php.ini such that mssql.secure_connection = On [was Off
for awhile]
* Telnet-ed into the SQL server...telnet [servername].case.edu 1433'
produces a positive response.
* Confirmed a zillion times that the MSSQL extension is functional.

Any ideas? If I don't fix this, I have to learn ASP in 24 hours.

Thanks.

Apr 24 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
sp*******@gmail.com wrote:
I have a server with Windows 2000, PHP 5, IIS and SQL Server 2000
running. Individually, each works great. When trying to bring PHP and
MSSQL together, though, I'm tearing my hair out...it just will not
connect. Not even an error message.
use Linux... :)

--
iTech Consulting Services Limited
Expert of ePOS solutions
Website: http://www.itech.com.hk (IE only)
Tel: (852)2325 3883 Fax: (852)2325 8288
Apr 24 '07 #2

P: n/a
TMM
On Mon, 23 Apr 2007 20:57:45 -0700, spamguy21 wrote:
I have a server with Windows 2000, PHP 5, IIS and SQL Server 2000
running. Individually, each works great. When trying to bring PHP and
....
<?php
$server = "localhost"; // have also tried "[servername]", "localhost:
1433" and "[servername]:1433"
I've tried to run mssql express like this and that connection faile until
I entered the correct "path" (I'm really unsure here, what to call it) to
the server. I also never got use for the port, when I did this:

$config['Database']['server'] = 'HOST\SQLEXPRESS';

After this, the connection worked all fine, except for the user-rights I
had to fix first.

Apr 24 '07 #3

P: n/a
TMM
On Mon, 23 Apr 2007 20:57:45 -0700, spamguy21 wrote:

I have a server with Windows 2000, PHP 5, IIS and SQL Server 2000
running. Individually, each works great. When trying to bring PHP and
...

<?php
$server = "localhost"; // have also tried "[servername]", "localhost:
1433" and "[servername]:1433"
I've tried to run mssql express like this and that connection failed until
I entered the correct "path" (I'm really unsure here, what to call it) to
the server. I also never got use for the port, when I did this:

$config['Database']['server'] = 'HOST\SQLEXPRESS';

After this, the connection worked all fine, except for the user-rights I
had to fix first.
Apr 24 '07 #4

P: n/a
sp*******@gmail.com wrote:
I have a server with Windows 2000, PHP 5, IIS and SQL Server 2000
running. Individually, each works great. When trying to bring PHP and
MSSQL together, though, I'm tearing my hair out...it just will not
connect. Not even an error message.
Have you looked at the event viewer? If you didn't specify for PHP to
log to a file, that's where the errors go...
>
Consider the code:

<?php
$server = "localhost"; // have also tried "[servername]", "localhost:
1433" and "[servername]:1433"
$username = "administrator"; // Windows username
$password = "[password]";
if (!mssql_connect($server, $username, $password))
echo "Could not connect.<p>";
?>
I don't know about MSSQL, but shouldn't you use a MSSQL user (as opposed
to a windows user)?

Apr 24 '07 #5

P: n/a
On Apr 23, 11:57 pm, spamgu...@gmail.com wrote:
I have a server with Windows 2000, PHP 5, IIS and SQL Server 2000
running. Individually, each works great. When trying to bring PHP and
MSSQL together, though, I'm tearing my hair out...it just will not
connect. Not even an error message.

Consider the code:

<?php
$server = "localhost"; // have also tried "[servername]", "localhost:
1433" and "[servername]:1433"
$username = "administrator"; // Windows username
$password = "[password]";
if (!mssql_connect($server, $username, $password))
echo "Could not connect.<p>";
?>

When thinking about all the things I've tried based on the wisdom of
the Internet, I'm stunned it still doesn't work:
* Upgraded the ntwdblib.dll file that PHP uses to 8.0.194, the latest
version
* Configured php.ini such that mssql.secure_connection = On [was Off
for awhile]
* Telnet-ed into the SQL server...telnet [servername].case.edu 1433'
produces a positive response.
* Confirmed a zillion times that the MSSQL extension is functional.

Any ideas? If I don't fix this, I have to learn ASP in 24 hours.

Thanks.
I highly suggest using the packaged ODBC functions instead. I use
MSSQL 05/Server2003/IIS6, mssql_* never worked for me but using ODBC
is flawless. Hope this helps!

Apr 24 '07 #6

P: n/a
On Apr 24, 5:57 am, spamgu...@gmail.com wrote:
I have a server with Windows 2000, PHP 5, IIS and SQL Server 2000
running. Individually, each works great. When trying to bring PHP and
MSSQL together, though, I'm tearing my hair out...it just will not
connect. Not even an error message.

Consider the code:

<?php
$server = "localhost"; // have also tried "[servername]", "localhost:
1433" and "[servername]:1433"
$username = "administrator"; // Windows username
$password = "[password]";
if (!mssql_connect($server, $username, $password))
echo "Could not connect.<p>";
?>

When thinking about all the things I've tried based on the wisdom of
the Internet, I'm stunned it still doesn't work:
* Upgraded the ntwdblib.dll file that PHP uses to 8.0.194, the latest
version
* Configured php.ini such that mssql.secure_connection = On [was Off
for awhile]
* Telnet-ed into the SQL server...telnet [servername].case.edu 1433'
produces a positive response.
* Confirmed a zillion times that the MSSQL extension is functional.

Any ideas? If I don't fix this, I have to learn ASP in 24 hours.

Thanks.
Is SQL Authentication turned on on the server? If you set
mssql.secure_connection to true, then Windows domain authentication is
used. The username and password passed to mssql_connect() will be
ignored. Unless the user that IIS runs as has access to the database,
it's not going to work.

Apr 25 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.