为什么我的程序将信息发送到不存在的页面?

时间:2018-08-13 20:51:43

标签: php http-status-code-404

我正在使用PHP进行一个小项目。有各种页面保留用户信息。现在,我正在尝试使用以下功能让用户输入主题,以延续到名为topic.php的单独页面上:

function dispsubcategories($parent_id){
    include ('../db.php');
    $select = mysqli_query($mysqli, "SELECT cat_id, subcat_id, 
    subcategory_title, subcategory_descr FROM categories, subcategories
                                 WHERE ($parent_id = categories.cat_id) 
                                 AND ($parent_id = subcategories.parent_id)");
    echo "<tr><th width='90%'>Categories</th><th width='10%'>Topics</th></tr>";

    while($row = mysqli_fetch_assoc($select)){
       echo "<tr><td class='category_title'><a href='topics.php".$row['cat_id']."/".$row['subcat_id']."'>
                ".$row['subcategory_title']."<br/>";
       echo $row['subcategory_descr']."</a></td>";
       echo "<td class='num-topics'>".getnumtopics($parent_id, $row['subcat_id'])."</td></tr>";
    }
}

//Displays categories
function getnumtopics($cat_id, $subcat_id){
    include ('../db.php');
    $select = mysqli_query($mysqli, "SELECT category_id, subcategory_id FROM 
                           topics WHERE ".$cat_id." = category_id
                           AND ".$subcat_id." = subcategory_id");
    $get = mysqli_num_rows($select);

    return $get;
}


//Displays Topics Within categories
function disptopics($cid, $scid){
    include ('../db.php');
    $select = mysqli_query($mysqli, "SELECT topic_id, author, title, 
                                     date_posted, views, replies 
                                     FROM categories, subcategories, topics
                                     WHERE ($cid = topics.category_id) AND 
                                     ($scid = topics.subcategory_id) AND 
                                     ($cid = categories.cat_id) AND 
                                     ($scid = subcategories.subcat_id) 
                                     ORDER BY topic_id DESC");
}

很抱歉,缩进将其输入有点混乱。

无论如何,您可以从中看到我的功能是在单击类别时将用户发送到topic.php,但是由于某种原因,当我单击类别时,文件路径在顶部显示屏幕:

enter image description here

它被发送到topic1.php,但我不断收到404错误。据我所知,我的代码中没有任何地方列出该文件,但是其中有很多我无法确定我是否缺少某些文件。

有人可以发现问题吗?

1 个答案:

答案 0 :(得分:1)

据我所知,您在

之后缺少斜杠
 <a href='topics.php

所以试试这个

<a href='topics.php/".$row['cat_id']."/".$row['subcat_id']."'>
            ".$row['subcategory_title']."<br/>";