0

これが私のコードです:

    $link=mssql_connect($server, 'username','password');
if (!$link) {
    die('Something went wrong while connecting to the mssql database, it could be offline! ' . mssql_get_last_message());
}
mssql_select_db('GunzDB', $link);
$result="SELECT * FROM Account WHERE UserID = '$username'";

if(mssql_num_rows($result) > 0){
    echo "That username is already in use!";
} else{
    $result="SELECT * FROM Account WHERE Email = '$email'";

    if(mssql_num_rows($result) > 0){
        echo "That email is already in use!";
    } else{

        $query="INSERT INTO Account (UserID, UGradeID, PGradeID, RegDate, Name, Email) VALUES ('" . $username . "','0','0','00:00','" . $name . "','" . $email . "')";
        if($query){
            $result="SELECT * FROM Account WHERE UserID = '$username'";

            $row = mssql_fetch_array($result);
            $AID=$row['AID'];
            $query="INSERT INTO Login (AID, Password) VALUES ('" . $AID . "','" . $password . "')";
            if($query){
                echo "<span style='color: lime'>Your account has been successfully created!</span>";
            } else{
                echo "error with MSSQL: " . mssql_get_last_message();
            }
        } else{
            echo "error with MSSQL: " . mssql_get_last_message();
        }
    }
}

これらのエラーが発生し続けます

Warning: mssql_num_rows() expects parameter 1 to be resource, string given in /var/www/gunz/register.php on line 81

Warning: mssql_num_rows() expects parameter 1 to be resource, string given in /var/www/gunz/register.php on line 86

Warning: mssql_fetch_array() expects parameter 1 to be resource, string given in /var/www/gunz/register.php on line 94

これらの行と関係があります

$result="SELECT * FROM Account WHERE UserID = '$username'";

$result="SELECT * FROM Account WHERE Email = '$email'";

$result="SELECT * FROM Account WHERE UserID = '$username'";
4

3 に答える 3

1

クエリを実行しません:

$result= "SELECT * FROM Account WHERE UserID = '$username'";
if (mssql_num_rows($result) > 0){

そのはず :

$result = mssql_query("SELECT * FROM Account WHERE UserID = '$username'");
if (mssql_num_rows($result) > 0){
于 2013-04-08T10:39:08.037 に答える
1

入力として文字列を与えるべきではありませんmssql_num_rows

実行後に取得したリソースである必要がありますmssql_query

お気に入り

$query = mssql_query('SELECT * FROM a');

echo mssql_num_rows($query);

ではない

$query = 'SELECT * FROM a';

echo mssql_num_rows($query);
于 2013-04-08T10:39:32.370 に答える