【发布时间】:2021-06-20 06:15:10
【问题描述】:
如果 url 中没有 id,我想从数据库中获取 id,然后使用 id 重定向到同一页面
if(!isset($_GET['id'])){
$st = $db->query("select id from video where ind = 0 limit 1");
$st->execute();
$id = $st->fetchColumn();
header('location: index.php?id='.$id);
}
$urid = $_GET['id']; // line 15
一切正常,页面被重定向,id 在那里,但系统会创建一个 error.log 文件说:
Undefined array key "id" ... on line 15
那么为什么系统会产生这个错误
重定向应该在line 15之前发生
【问题讨论】: