I have problem to connect to MsSql via ODBC:
i have 2 types of error

1) if I coonecting as
$conn=odbc_connect($db,$user,$pass);
i have this error:
SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user '\'.,
SQL state 28000 in SQLConnect ...

2) $conn=odbc_connect("DRIVER=SQL Server;SERVER=".$ser.";UID=".$user.";PWD=".$pass.";
DATABASE=".$db.";Address=".$ser.",1433","","");
this error:
SQL error: [Microsoft][ODBC Driver Manager] Invalid string or buffer length,
SQL state S1090 in SQLConnect in

second sample gets from php.net
if you can help me - please help.
i Use W2k+apache 1.3.27 + PHP 4.2.3

    Use MS SQL login and password, not Windows login and password

      I use MS SQL user and login 🙁
      may be i incorrect configured SQL Server in ODBC ?

        Maybe, change sample 2:

        $conn=odbc_connect("DRIVER=SQL Server;SERVER=".trim($ser).";UID=".trim($user).";PWD=".trim($pass).";DATABASE=".trim($db).";1433;","","");  

        or

        $conn=odbc_connect("DRIVER=SQL Server;SERVER=".trim($ser).";UID=".trim($user).";PWD=".trim($pass).";DATABASE=".trim($db).";","","");  

          It helps, but:

          Login failed for user 'apolsa'. Reason: Not associated with a trusted SQL Server connection., SQL state 28000 in SQLConnect

          what does it mean ?

          I can connect to database, using this login and password with SQL server manager 🙁

            i localized problem - if Apache works as service - is problem
            if like simple program - no. hmmmm.... but I want use Apache as service

              Maybe, in php.ini
              mssql.secure_connection = On

              It must be

              ; Use NT authentication when connecting to the server
              mssql.secure_connection = Off

              I don't think that this parameter take effect on ODBC connections, but I don't know...

                This paremetr is off (i tried this)
                mssql.secure_connection = Off

                I solve this problem by setting to Apache logon as domain user to my PC (i think this is a part of "Run As" service). hmm. strange, strange.....
                but it works 🙂
                (ja jego nagnil i postavil v pozu 🙂

                  Can you explain explicitly, what are you doing? I have similar problem and don't find solving yet...

                    in the srvices->apache->logon->"check" this account - enter your domain/login and password 2 times
                    that all

                      Great thanks!!! It's work!

                        Write a Reply...