php与MSsql服务器

时间:2014-04-02 08:02:26

标签: php sql-server

我已将php_pdo_sqlsrv_54_ts.dll和php_sqlsrv_54_ts.dll都放在C:\ xampp \ php \ ext文件夹中 ---------------------- php.ini文件------------------------ -

extension=php_bz2.dll
extension=php_sqlsrv_54_ts.dll
extension=php_pdo_sqlsrv_54_ts.dll
extension=php_curl.dll
extension=php_mbstring.dll
extension=php_exif.dll
;extension=php_fileinfo.dll
extension=php_gd2.dll
extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll

------------------------------ connectionfile ---------------- -----

<?php
$serverName="KEVONIA-PC\SQLEXPRESS";

$connecttioninfo=array("Database"=>"P_CAT_teetws");

$conn = sqlsrv_connect($serverName,$connecttioninfo);
if( $conn ){
     echo "Connection Establised.<br/>";
    }else{
        echo "Connection not  Establised.<br/>";
        die(print_r(sqlsrv_errors(),true));
        }

?>

------------------------------ loginexecfile ---------------- -----

//Create query
    $qry="SELECT * FROM member WHERE username='$username' AND password='$password'";
    $result=mssql_query($qry);

    //Check whether the query was successful or not
    if($result) {
        if(mssql_num_rows($result) > 0) {
            //Login Successful
            session_regenerate_id();
            $member = mssql_fetch_assoc($result);
            $_SESSION['SESS_MEMBER_ID'] = $member['mem_id'];
            $_SESSION['SESS_FIRST_NAME'] = $member['username'];
            $_SESSION['SESS_LAST_NAME'] = $member['password'];
            session_write_close();
            header("location: home.php");
            exit();
        }else {
            //Login failed
            $errmsg_arr[] = 'user name and password not found';
            $errflag = true;
            if($errflag) {
                $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
                session_write_close();
                header("location: index.php");
                exit();
            }
        }
    }else {
        die("Query failed");

}

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

1 个答案:

答案 0 :(得分:0)

您可以在此处找到mssql_query的完整详细信息:http://www.php.net/manual/en/book.mssql.php

但是因为你接收undefined可以请检查php版本和mssql扩展名:

创建一个info.php页面并粘贴:

在这里您可以找到更多详细信息: http://msdn.microsoft.com/en-US/library/cc793139%28v=SQL.90%29.aspx

===个人建议=== 我的建议是使用MySQL与PHP,但这是你的选择,取决于要求,但我更喜欢PHP与MySQL和Asp.net与MSSQL。