我需要改变什么来使这个工作在SQL服务器上

时间:2013-05-23 13:43:41

标签: php html sql-server dreamweaver

我正在使这个代码在sql服务器上工作,但我不知道如何去做我已经将所有MySQL命令改为mssql但我不确定还有什么需要改变我错过了一个dll或因为我收到这样的错误信息:

致命错误: Call to undefined function mssql_connect() in on line 8 Call Stack: 0.0012 353392 1. {main}()login.php:0

以下是我更改用户名和密码的代码,原因很明显,

<?php
    session_start();

    $username = $_POST['txt_username'];
    $password = $_POST['txt_password'];
if ($username&&$password){  

    $connect = mssql_connect("server", "username", "password") or die("No Server Found");

    mssql_select_db("database name") or die("No Connection");

    $query = mssql_query("SELECT * FROM account WHERE username='$username'");
    $numrows = mssql_num_rows($query); 

    if($numrows !=0){
        while ($rows = mssql_fetch_assoc($query)){

            $dbusername = $row['username'];
            $dbpassword = $row['password'];
            }
     if ($username == $dbusername && $password == dbpassword) {

         echo "Login Successful. <a href='homepage.php'></a>";

         $_SESSION['username'] = $dbusername;

             } elseif ($username == '' || $password == '') {

             die("Please enter a username and password");

                 } elseif (empty($dbusername)) {

                     die("This account does not exsist");

                     } else {
                           die("Please enter a username and password");
                            }
                }

}?>

2 个答案:

答案 0 :(得分:0)

使用PDO,不推荐使用myssql,请看一下:

mssql_connect no longer working as of PHP 5.3

在这里

http://www.php.net/manual/en/ref.pdo-sqlsrv.php

答案 1 :(得分:0)

创建此页面:

<?php
  php_info()
?>

然后访问该页面将告诉您有关如何设置PHP环境的所有信息。我怀疑你没有启用mssql模块。