note 27522 added to function.mssql-connect
| From: | kokice_77 at yahoo dot com | Date: | Mon, 09 Dec 2002 21:13:13 +0000 |
| Subject: | note 27522 added to function.mssql-connect | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-40627@lists.php.net to get a copy of this message | ||
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.
--
http://www.php.net/manual/en/function.mssql-connect.php
http://master.php.net/manage/user-notes.php?action=edit+27522
http://master.php.net/manage/user-notes.php?action=delete+27522
http://master.php.net/manage/user-notes.php?action=reject+27522