Can't connect to sql with php!?

Discussion in 'Databases' started by Hud, Sep 27, 2008.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hud

    Hud

    Hi, I posted this in PHP also, because I wasn't sure if it was a php or sql problem.

    I can't get my code to connect to the SQL Server 2005 database. My code is very simple:
    <?php
    $ConnString='DRIVER={SQL Server};SERVER=sql2k512.discountasp.net;DATABASE=SQL2005_etc';
    $DB_User='SQL2005_etc_user';
    $DB_Passwd='PASSWORD';
    $Connect = odbc_connect($ConnString, $DB_User, $DB_Passwd) or die ('Unable to connect to database');

    if($Connect){
    echo 'yay';
    }
    ?>

    Every time I try to go to that page, it just says:
    Warning: odbc_connect() [function.odbc-connect]: SQL error: [iODBC][Driver Manager]Data source name not found and no default driver specified. Driver could not be loaded, SQL state IM002 in SQLConnect in /Library/WebServer/Documents/hudpro/test/test_connect.php on line 5
    Unable to connect to database


    Any help would be appreciated. I'm completely stuck and have an approaching deadline! Thanks!
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page