我有一个PHP脚本可以做几件事。
我正在使用准备好的陈述。一切都很好,直到我尝试增加用户的版本。当我添加这个语句时,什么都不会回显,甚至不是列表。如果我删除更新代码,列表将回显。问题只发生在POST期间。
评论如下:
<?php
include('connections/conn.php');
$userZip = $_GET['zip'];
$uGoogleSecret = $_POST['secret'];
$testsql = $conn->prepare('SELECT * FROM pffusers where uGoogleSecret = ?');
$testsql->bind_param("i",$uGoogleSecret);
$testsql->execute();
$testsql->store_result();
$rarray = array();
if($testsql->num_rows==0){
$zipSql = $conn->prepare('SELECT * FROM qryzipsphones where zCode = ? and pActive=1;');
$zipSql->bind_param("s",$userZip);
$zipSql->execute();
$zipSql->store_result();
if($zipSql->num_rows==0){
$finalZipSql = $conn->prepare('SELECT * FROM qryzipsphones where zCode = 17103 and pActive=1;');
} else{
$finalZipSql = $zipSql;
}
} else{
$zipSql = $conn->prepare('SELECT * FROM qryzipsphones where zCode = ? and pActive=1;');
$zipSql->bind_param("s",$userZip);
$zipSql->execute();
$zipSql->store_result();
if($zipSql->num_rows==0){
$finalZipSql = $conn->prepare('SELECT * FROM qryzipsphones where zCode = 17103 and pActive=1;');
} else{
$finalZipSql = $zipSql;
}
}
$finalZipSql->execute();
$res = $finalZipSql->get_result();
while($finalZip=$res->fetch_assoc()){
array_push($rarray,array(
'pid'=>$finalZip['pid'],
'pName'=>$finalZip['pName'],
'pDisplayNumber'=>$finalZip['pDisplayNumber'],
'pNumber'=>$finalZip['pNumber'],
));
}
$finalZipSql->close();
//Problem begins here
$usql = $conn->prepare('SELECT * FROM pffusers where uGoogleSecret = ?');
$usql->bind_param("i",$uGoogleSecret);
$usql->execute();
$usql->store_result();
if($usql->num_rows==1){
$urow = $usql->fetch_assoc();
$uid = $urow['uid'];
$uversion = $urow['uVersion'];
$uversion++;
$uUser = $conn->prepare('update pffusers set uVersion=? where uid=?;');
$uUser->bind_param("ii",$uversion,$uid);
$uUser->execute();
}
//Problem ends here
echo json_encode(array('result'=>$rarray));
?>