我有这段代码:
private function grabCurrentUser() {
$this->id = parent::secure($_GET['cid']);
$params = array( ':user_id' => $this->id );
$stmt = parent::query("SELECT * FROM users WHERE user_id = :user_id;", $params);
if( $stmt->rowCount() < 1 ) parent::displayMessage("<div class='alert alert-error'>"._('No such user!')."</div>");
foreach ($stmt->fetch(PDO::FETCH_ASSOC) as $field => $value)
$this->options[$field] = $value;
}
我想替换它上面的错误消息,所以不要有这个错误消息:
parent::displayMessage("<div class='alert alert-error'>"._('No such user!')."</div>
我想像这样包含 index.php:
include_once(cINC . 'index.php');
那么如何将它从显示错误消息替换为仅包含 index.php?
我试过这个:
private function grabCurrentUser() {
$this->id = parent::secure($_GET['cid']);
$params = array( ':user_id' => $this->id );
$stmt = parent::query("SELECT * FROM users WHERE user_id = :user_id;", $params);
if( $stmt->rowCount() < 1 ) include_once(cINC . 'index.php');
foreach ($stmt->fetch(PDO::FETCH_ASSOC) as $field => $value)
$this->options[$field] = $value;
}
但是得到了这个错误:
Warning: Invalid argument supplied for foreach()
提前致谢