简体   繁体   English

PHP-调用未定义函数mssql_query()

[英]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. 我已使用以下php代码显示sql表中的行数,但出现以下错误消息。

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. 如果使用sql server,请使用此代码。 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. 这意味着您正确安装了MS SQL驱动程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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