当我通过 json 请求同一行时更新 MySQL 行时,我收到旧值 服务器上的值在 phpMyAdmin 中正确。调用 2 或 3 次后收到正确的值。
$id=$_POST['id'];
$type=$_POST['type'];
$study=$_POST['study'];
$text=$_POST['text'];
$date=$_POST['date'];
$picture=$_POST['picture'];
$notes=$_POST['notes'];
$text= addslashes($text);
$text=htmlspecialchars($text);
$notes= addslashes($notes);
$notes= htmlspecialchars($notes);
$continued = mysql_connect(localhost,somebodyuser,password);
if($continued){
echo("");
}else{
echo("Connection is fail");
}
mysql_select_db("u599749231_rose")or die("cannot select DB");
mysql_query("set character_set_server='utf8'");
mysql_query("set names 'utf8'");
$update=mysql_query("UPDATE achive SET type= '$type', study = '$study', text= '$text',
date = '$date' , picture ='$picture' , notes = '$notes' WHERE id='$id'");
if($update)
{
echo'1';
}
else
{
echo'0';
}
mysql_close($continued);
?>
最佳答案
听起来您的 PHP 脚本正在返回缓存的数据。在将任何数据返回给客户端之前,我总是在 PHP 脚本中使用以下 header 调用:
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
希望对你有帮助...
关于php - 当我通过 json 请求同一行时更新 MySQL 行时,我收到旧值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22585309/