Download Wamp.
Next, Download the newest add-on of php.
Next, download ntwdblib.dll: HERE
Steps:
1) Install WAMP
2) Install latest php addon.
3) Click on the WAMP icon -> PHP -> Version and select 5.3.1.
4) Click on the WAMP icon -> PHP -> PHP Extensions then check php_mssql andphp_pdo_mssql.
(Wamp will restart and give you few errors, ignore them)
5) Restart WAMP one more time to ensure settings are saved.
6) Finally, place ntwdblib file in the two following directories:
wamp\bin\php\php5.3.1
wamp\bin\apache\apache2.2.11\bin
7) Restart wampserver, and you're finished!
Still the problem exists, open php.ini file and edit the following line
;extension=php_mssql.dll
Uncomment the above line then it looks like
extension=php_mssql.dll
Save the file and restart the Wamp server.
Below is the sample php script for MS SQL connection
<?php
$Server = "localhost";
$User = "your_name";
$Pass = "your_password";
$DB = "examples";
//connection to the database
$dbconn = mssql_connect($Server, $User, $Pass)
or die("Couldn't connect to SQL Server on $Server");
//select a database to work with
$selected = mssql_select_db($DB, $dbconn)
or die("Couldn't open database $myDB");
//declare the SQL statement that will query the database
$query = "SELECT name from test ";
//execute the SQL query and return records
$result = mssql_query($query);
$numRows = mssql_num_rows($result);
echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>";
//display the results
while($row = mssql_fetch_array($result))
{
echo "<br>" . $row["name"];
}
//close the connection
mssql_close($dbconn);
?>
For XAMPP:
Edit the below code in php.ini file
;extension=php_mssql.dll
Uncomment the above line then it looks like
extension=php_mssql.dll