mssql_rows_affected返回错误的行数

时间:2013-12-30 12:02:42

标签: php mysql sql

代码如下,是一个PHP脚本,通过单击链接激活用户的帐户。 执行SQL查询以更新表。更新很好但最后我显示了一条消息,如果激活成功与否。但是mssql_rows_affected可能会返回0,所以即使更新成功,我也会收到错误的消息。无法理解什么是错的。提前谢谢。

$account = $_GET['account'];
$code = $_GET['code'];

$account = antiinjection($account);
$code = antiinjection($code);

connectdb($CONFIG['dbdbname'], $CONFIG['dbaddress'], $CONFIG['dbuser'], $CONFIG['dbpass']);
mssql_query (sprintf(UPDATE_PAY_STAT, $account, $code));
mssql_query("COMMIT");
$rowsaffected = mssql_rows_affected();
$message =  "
                <div align=center>The account {$account} has been activated! Have fun!</div>
            ";

if( $rowsaffected != 0 ){
echo "$message";
}
else
{
    $message =  "
                <div align=center>The account {$account} has not been activated due to an error. Please contact the Account Support.</div>
                ";
}

echopage('header', 'Activate');
echo($message);
echopage('footer', '');

1 个答案:

答案 0 :(得分:0)

因为我无法让mssql_affected_rows()工作,所以我这样做了。我添加了1个sql查询,检查x帐户名是否有pay_stat ='1'。谢谢你的回答!

   $link=mssql_query (sprintf(SELECT_COUNT_PS, $account));
$row = mssql_fetch_row($link);

if( $row[0] == '1' ){
$message =  "
                <div align=center>The account {$account} has been activated! Have fun!</div>
            ";
}
else
{
    $message =  "
                <div align=center>The account {$account} has not been activated due to an error. Please contact the Account Support.</div>
                ";
}