PHP ODBC Connection failed , Sql Server 2000, help

Discussion in 'QnA (read only)' started by Butterfly, Oct 1, 2004.

Thread Status:
Not open for further replies.
  1. Butterfly

    Butterfly New Member

    Joined:
    Sep 20, 2004
    Messages:
    87
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Thimphu
    Folks ,

    AM trying to make connection with the Northwind database(SQL server 2000 usiung PHP but i get this error . Help me , am begineer

    ***********************************************************
    Warning: odbc_connect(): SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection., SQL state 28000 in SQLConnect in c:\web\odbc_connection.php on line 2
    Connection Failed:

    **********************************************************

    ************************************This is my code *********
    <html><body><?php
    $conn=odbc_connect('northwind','','');
    if (!$conn)
    {
    exit("Connection Failed: " . $conn);
    } $sql="SELECT * FROM customers"; $rs=odbc_exec($conn,$sql); if (!$rs)
    { exit("Error in SQL");
    } echo "<table><tr>";echo "<th>Companyname</th>";
    echo "<th>Contactname</th></tr>";while (odbc_fetch_row($rs))
    {$compname=odbc_result($rs,"CompanyName");$conname=odbc_result($rs,"ContactName");echo "<tr><td>$compname</td>";echo "<td>$conname</td></tr>";}
    odbc_close($conn);echo "</table>";?></body></html>
     
  2. walking-techie

    walking-techie New Member

    Joined:
    Aug 9, 2004
    Messages:
    190
    Likes Received:
    0
    Trophy Points:
    0
    did u create a dsn
    i thnk thats the problem
     
  3. #/bin/sh

    #/bin/sh New Member

    Joined:
    Apr 20, 2004
    Messages:
    213
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    42.65 N 73.76 W
    $conn=odbc_connect('northwind','','');

    needs to contain your user name and password i belive like...

    $conn=odbc_connect('northwind','$USERNAME','$PASSWORD'); (assuming i don't have that backwards)

    Good Luck!
     
  4. GNUrag

    GNUrag FooBar Guy

    Joined:
    Jun 22, 2004
    Messages:
    1,246
    Likes Received:
    5
    Trophy Points:
    0
    Location:
    Interwebs
    Nope... he did'nt create a DSN... i talked to him on messenger... Did you succeed in creating a Data Source ?
     
  5. Deep

    Deep Version 2.0

    Joined:
    Jan 23, 2004
    Messages:
    977
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Mumbai
    yup i too think, that could be the problem...

    Deep
     
  6. OP
    OP
    Butterfly

    Butterfly New Member

    Joined:
    Sep 20, 2004
    Messages:
    87
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Thimphu
    Guys < Thanks My ODBC Connection worked

    Folks

    Yeah my connection part worked , am so happy , catch ya latter
     
Thread Status:
Not open for further replies.

Share This Page