Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
第9行C:includes\topic\u list.php中未定义的索引:topic_Php_Mysql_Error Handling_Syntax Error_Undefined - Fatal编程技术网

第9行C:includes\topic\u list.php中未定义的索引:topic

第9行C:includes\topic\u list.php中未定义的索引:topic,php,mysql,error-handling,syntax-error,undefined,Php,Mysql,Error Handling,Syntax Error,Undefined,您试图使用$\u GET['topic'],但没有先检查它是否存在,这就是为什么会出现该错误。我建议您首先使用is_set()或empty()测试变量是否存在 <?php $qr_topic = @mysql_query("SELECT * FROM topics"); while ($topic = @mysql_fetch_array($qr_topic)) {

您试图使用$\u GET['topic'],但没有先检查它是否存在,这就是为什么会出现该错误。我建议您首先使用is_set()或empty()测试变量是否存在

            <?php 
                $qr_topic = @mysql_query("SELECT * FROM topics");
                while ($topic = @mysql_fetch_array($qr_topic)) {
                    $highlight = "";
                    **if ($topic['name'] == $_GET['topic'] || $post['topic_id'] == $topic['id']) {**
                        $highlight = "class='highlight'";
                    }
                    echo "<li ".$highlight."><a href='index.php?topic=".$topic['name']."'>".$topic['name']."<img src='img/".$topic['image']."'  width='195' height='90' /></a></li>";
                }
            ?>