Connecting to a MS SQL Server 2000
 
It took me a while to figure out, how to connect to a Microsoft SQL Server 2000 with php. In the end, it's very simple:
<?php
// The Servername of the SQL Server the instance name of the database
// If you didn't specify an instance name, you can connect using $dbhost="SERVER";
$dbhost="SERVERINSTANCE";
// User is by default "sa" (System Administrator) and the pass is by default empty.
$dbuser="sa";
// Default password for user sa is empty...
$dbpass="";
// Northwind is a database with example tables, i've chosen to select the employees table.
$dbname="Northwind";
// The connection and database selection functions
$db=mssql_connect($dbhost,$dbuser,$dbpass);
mssql_select_db($dbname,$db);

// finally the loop with First Name and Last Name
$sql = "SELECT LastName, FirstName FROM Employees ";
$result = mssql_query($sql);
while($data=mssql_fetch_array($result))
   {
   echo $data['FirstName']." ".$data['LastName']."<br>";
   }
?>

Make sure you have:
A) Installed the extensions php_mssql.dll and php_msql.dll and set them up in php.ini.
B) Activated "mixed authentication mode (Windows/SQL Server)" for your database instance.
If it still doesn't work, ask for with a comment.
 
admin / Dec 04, 2004
   
 
 
Login: 
Pass: 
 
 
     
     
2004 - 2019 / lookass.ch
makememad@lookass.ch