【发布时间】:2010-12-20 00:27:18
【问题描述】:
我有一个网页(我们称之为 A.html)。 A.html 有一些 javascript,它使用简单的 document.location="B.php" 将页面切换到动态 php 页面(我们称之为 B.php)。 B.php 根据它看到的 cookie 运行 mysql 查询,并根据 mysqli->affected_rows 变量返回结果。但是,每次页面切换时 mysqli->affected_rows 都等于 0,即使 mysql 表确实按照预期的方式进行了更改。有趣的是,当我使用 url 栏(或刷新页面)直接进入 B.php 时,mysqli->affected_rows 是 1,就像它应该的那样。
查看wireshark,两个GET请求之间的唯一区别是第二个(非javascript)有一行Cache-Control: max-age=0。有谁知道为什么这会影响任何事情,如果有办法解决这个问题?
编辑:这是代码
$req = $mysqli->prepare('update users set sts=NOW() where i=? and sid=? and sip=? and NOW()-sts <= '.$authentication_timeout.';');
if ($mysqli->error) {
log_mysql_error($mysqli);
die('Unexpected error:'.$mysqli->error);
}
$req->bind_param('sss',$uid,$sid,$_SERVER['REMOTE_ADDR']);
$req->execute();
print $mysqli->affected_rows;
$req->close();
【问题讨论】:
标签: php javascript mysql cache-control rows-affected