note 27522 deleted from function.mssql-connect by felipe

From: Date: Sun, 30 Dec 2007 18:38:04 +0000
Subject: note 27522 deleted from function.mssql-connect by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-134397@lists.php.net to get a copy of this message
Note Submitter: kokice_77 at yahoo dot com ---- I'm running Windows XP, SQLServer 2000, Apache 1.3.23 and PHP 4.2.3. This worked perfecty for me: <?php $myServer = "localhost"; $myUser = "sa"; $myPass = "password"; $myDB = "Northwind"; $s = @mssql_connect($myServer, $myUser, $myPass) or die("Couldn't connect to SQL Server on $myServer"); $d = @mssql_select_db($myDB, $s) or die("Couldn't open database $myDB"); $query = "SELECT TitleOfCourtesy+' '+FirstName+' '+LastName AS Employee "; $query .= "FROM Employees "; $query .= "WHERE Country='USA' AND Left(HomePhone, 5) = '(206)'"; $result = mssql_query($query); $numRows = mssql_num_rows($result); echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>"; while($row = mssql_fetch_array($result)) { echo "<li>" . $row["Employee"] . "</li>"; } ?> Running example from this site: http://www.devarticles.com/art/1/100/3 The thing is, you must choose authentication from windows AND SQL Server. Otherwhise it will not work. During the installation of SQLServer you choose this option, and set a password to the user "sa". Hope it helps.

« previous php.notes (#134397) next »