简体   繁体   中英

Php - Call to undefined function mssql_query()

I have used the following php code to show the number of rows from sql table but I am getting below error message.

Fatal error: Call to undefined function mssql_query()
             in D:\wamp\www\thereport24\gp.php
             on line 22

my code:

$conn = odbc_connect('gpcon','',''); 
if ($conn)
    {
    $query= "select * from SubscriberServices where SubscriptionGroupID like 'ms_gp_tr24bn_3333'";
    $results = mssql_query($query);
    $rows    = mssql_fetch_array($results);
    echo $rows[0];
    mssql_close($con); 
}

If you use sql server, use this code. This works for me:

<?php
    $serverName = "serverName"; 
    $options = array(  "UID" => "sa",  "PWD" => "Password",  "Database" => "DBname");
    $conn = sqlsrv_connect($serverName, $options);

    if( $conn ) {
         echo "Connection established.<br />";

         $query="select * from SubscriberServices where SubscriptionGroupID like 'ms_gp_tr24bn_3333'";
         $result = sqlsrv_query($conn,$query);
         sqlsrv_close($conn);


    }else{
         echo "Connection could not be established.<br />";
         die( print_r( sqlsrv_errors(), true));
    }

?>

if it returns "Connection established." it's mean you install MS SQL Drivers correct.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM