Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ODBC connection

Status
Not open for further replies.
Joined
Feb 1, 2005
Messages
144
Location
US
Hi I keep getting the error below when attempting to connect to a SQL 2000 database:
Warning: odbc_connect(): SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'., SQL state 28000 in SQLConnect in on line 3
Connection Failed:

My code
Code:
<?php
//bes is the system dsn
$connect = odbc_connect('bes','myuserid','*****');
if (!$connect)
  {exit("Connection Failed: " . $conn);}


$sql = "SELECT * FROM userconfig"; 
$rs = odbc_exec($conn, $sql);
odbc_fetch_row($rs);
$users=odbc_result($rs,"DisplayName");

echo $DisplayName;

$odbc_close($connect);

php?>

I think I have access to the DB because I can use SQL query analazyser and also when I create the DSN I use NT auth and have no problems.

What does the above error point to?
Thanks
 
Using your code, I think you have a typo. You use $connect and $conn as if they were the same thing. I think you've forgotten to port the following line to use $connect:

Code:
$rs = odbc_exec($conn, $sql);
It's probably supposed to look like this:
Code:
$rs = odbc_exec($connect, $sql);

That doesn't necessarily help you with the error you are seeing though... it's implying that you don't have access to the database with that username. Well, that's how I read it.

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]

What is Javascript? faq216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top