Querying MSSQL with PHP

Status
Not open for further replies.

svdsinner

Ars Legatus Legionis
15,152
Subscriptor
OK, I'm stuck again on some basic things.
I'm running PHP 4.1.1 on W2K/IIS 5
MSSQL server is SQL2K, web server has latest MDAC installed.

After determining that MSAccess wouldn't handle what we needed (no surprise) I began trying to change my code over to accessing MSSQL.

1) Originally, I couldn't get the Username/Password to the MSSQL ODBC connection. I'd try:
code:<HR>
Code:
$con = odbc_connect("TestSQLDSN","Username", "Password");
(just as documented.) and I would get the error that NT Authority\Anonymous User was rejected, no matter what Username Password that it was passed.

2) Because of #1, I am experimenting with dumping ODBC and using the specific mssql functions in PHP. However, I am stuck on two things following this route:
A) I can't get the mssql_query() function to work. (Big problem) If I do:
code:<HR>
Code:
$con = mssql_connect("DWSQL","DWFETest","Password1");
echo "
Connection #$con
";
mssql_select_db("DWFETest1", $con);
$sqlstring = "SELECT * FROM [$Table]";
echo "
$sqlstring
";
$qTable = mssql_query($sqlstring);
I get "CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:" If I comment out the last line, I can see from the echo statements that everything is working except the last line. What is wrong with my syntax?
B) I can't get the mssql_num_fields() function to work. When I execute it, I recieve the same error as in #2A above.

Help! I need to get either 1 or 2 solved so that I can keep working.
 
Status
Not open for further replies.