我的 Nginx 服务器日志中出现标题错误。我已经检查了许多其他类似的问题,但没有成功。php 脚本按预期工作,但每次点击页面时都会出现错误。
这是受影响的代码:
$user_slug=$_GET['user-id'];
$where = array("user_url"=>$user_slug);
$user_info = $operation->select_record('*',$where,'tbl_users');
$user_name = $user_info[0]['user_name'];
$user_email = $user_info[0]['user_email'];
$user_text = $user_info[0]['user_text'];
而相关函数(select_record)如下:
function select_record($tblfld,$where,$table){
$sql = "";
$condition = "";
foreach ($where as $key => $value) {
$condition .= $key . "='" . $value . "' AND ";
}
$condition = substr($condition, 0, -5);
$sql .= "SELECT ".$tblfld." FROM ".$table." WHERE ".$condition;
$smt = $this->conn->prepare($sql);
$smt->execute();
return $smt->fetchAll();
}
我非常感谢这方面的一些帮助。
在访问之前检查您的结果数组..
$user_slug=$_GET['user-id'];
$where = array("user_url"=>$user_slug);
$user_info = $operation->select_record('*',$where,'tbl_users');
if (!empty($user_info)) {
$user_name = $user_info[0]['user_name'];
$user_email = $user_info[0]['user_email'];
$user_text = $user_info[0]['user_text'];
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句