note 27522 deleted from function.mssql-connect by felipe

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.