下面的代码是一个 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', '');
最佳答案
因为我无法让 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>
";
}
关于php - mssql_rows_affected 返回错误的行数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20839156/