当我通过json请求相同行时更新MySQL行我收到旧值

时间:2014-03-23 00:01:46

标签: php mysql jsonp

当我通过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);
 ?>

1 个答案:

答案 0 :(得分:0)

听起来您的PHP脚本正在返回缓存数据。在将任何数据返回给客户端之前,我总是在PHP脚本中使用以下标头调用:

header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");   // Date in the past

希望它有所帮助...