extension=php_mssql.dll
If the support exists then you will get the details like this below.
<?php
$serverName = "localhost";
$connectionOptions = array("Database"=>"myDB", "Uid"=>"user", "PWD"=>"password");
$conn = sqlsrv_connect($serverName, $connectionOptions);
if($conn) {
echo "Connected to MSSQL!";
} else {
echo "Connection failed!";
}
?>
$dbusername='username';
$dbpassword='password';
$servername='servername';
$link = mssql_connect ($servername,$dbusername,$dbpassword);
$dbusername='';
$dbpassword='';
$servername='';
$link= mssql_connect ($servername,$dbusername,$dbpassword);
$query="select * from emp_m ";
$qt=mssql_query($query);
while($nt=mssql_fetch_array($qt)){
echo "$nt[emp_no]"." $nt[name]";
echo "<br>";}
Or using sqlsrv_query() ( for modern PHP versions)
<?php
$query = "SELECT * FROM employees";
$stmt = sqlsrv_query($conn, $query);
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
print_r($row);
}
sqlsrv_close($conn);
?>
sqlsrv_query(): Part of the SQLSRV driver, designed to connect PHP to Microsoft SQL Server. It supports advanced features like prepared statements, parameterized queries, and error handling. Recommended for modern PHP versions.
$conn = sqlsrv_connect($serverName, $connectionOptions);
$query = "SELECT * FROM Users";
$result = sqlsrv_query($conn, $query);
mssql_query(): Part of the old mssql extension, deprecated in PHP 7. Limited functionality compared to sqlsrv_query(), and no longer recommended for new development.
$conn = mssql_connect($serverName, $username, $password);
$query = "SELECT * FROM Users";
$result = mssql_query($query, $conn);
Introduction to PHPCollect php.ini settings by using ini_get()
Guide to installation and How to write our first PHP Script