How to replace non exsiting mssql_query and mssql_connection functions

If you moved your php application to version 7.0+ then your application may stop working if you are using MSSQL.

I have created the following library to fix my problem and replace the non-existing function with their replacement.

if (function_exists(‘mssql_connect’)){
function mssql_connect($db_server, $db_user, $db_pass) {
global $link,$db_server,$db_user,$db_pass;
$connectionOptions = array(
“Uid”=> $db_user,
“PWD”=> $db_pass,
//Establishes the connection
$link = sqlsrv_connect($db_server, $connectionOptions);
if( $link ===false ) {
return $link;
function mssql_select_db($db_database, $link){
function mssql_query($query, $link = 0){
global $db_server,$db_user,$db_pass,$link;
if($link ==0){
$link = mssql_connect($db_server, $db_user, $db_pass);
$r = sqlsrv_query($link, $query,array(), array( “Scrollable” => ‘buffered’ ));
return $r;
function mssql_num_rows($r){
//return number of rows
function mssql_fetch_object($r){
//return objects
function mssql_close(){
function mssql_fetch_array($r){
//return array

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.