dqqpf32897 2013-06-14 07:58
浏览 123
已采纳

PHP致命错误:调用未定义的函数mssql_query()

So I keep getting this error when I want to query something to the ms sql server..

The connection is made with the database but the queries seem to fail.

The error log contains this:

    PHP Fatal error:  Call to undefined function mssql_query()

The code on the php:

session_start();
include_once("connect.php");
if (isset($_POST['username'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$sql = "SELECT * FROM test WHERE username='".$username."' AND password='".$password."'";
$res = mssql_query ($sql) or die(mssql_error());

if (mssql_num_rows($res) == 1) {
    $row = mssql_fetch_assoc($res);
    $_SESSION['uid'] = $row['id'];
    $_SESSION['username'] = $row['Username'];
    $_SESSION['afdeling'] = $row['Afdeling'];
    $_SESSION['mail'] = $row['Mail'];
              header("Location: test.php");
    exit();
} else {
    echo "Invalid login information. Please return to the previous page.";
    exit(); }  }  ?>

Does anybody knows what the problem is?

Thanks in advance!

connect.php code:

<?php
$serverName = "MTN-TEST"; //serverName\instanceName
$connectionInfo = array( "Database"=>"PROCES_TEST", "UID"=>"blaaa", "PWD"=>"blooo");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn ) {
     echo "<span style='color:green;'>Connection established.</span><br />";
}else{
     echo "<span style='color:red;'>Connection could not be established.</span><br />";
    die( print_r( sqlsrv_errors(), true));
}
?>
  • 写回答

3条回答 默认 最新

  • douquan3294 2013-06-14 08:11
    关注

    You don't have the MS SQL Drivers installed. You can check this with phpinfo();

    On Linux you need mssql.so or sybase.so With debian its apt-get install php5-sybase

    For windows take a look here: http://msdn.microsoft.com/en-US/library/cc793139%28v=SQL.90%29.aspx

    Drivers need to be configured for PHP to find the function mssql_...

    You could also look at PDO DB classes as they can connect to any DBS, you need the drivers installed tho.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改