0

我正在尝试回显到div中,但出现以下错误:

 Notice: Undefined index: count on $SESSION['count']  

当 $SESSION['error'] 被触发时,我收到以下错误:

 Undefined index: count on $SESSION['error']  

当 $SESSION['count'] 被触发时,我收到与上述类似的错误。

这是PHP中的代码。

<?php

        if(isset($_SESSION['error'])){

            } else { 

             foreach($_SESSION['search_output'] as $value){
                $value['links'];
                $value['title'];
                $value['page_body'];


                $title = $value['title'];
                $link = $value['links'];
                $body = $value['page_body'];

                $search_output .= "<a href='".$link."'>".$title."</a> - $body<br><br>";}
    }
    ?>

    <div id="topResult">
        <?php  echo $_SESSION['error']; unset($_SESSION['error']);?> 
        <?php  echo ($_SESSION['count']); unset($_SESSION['count']);?> 
    </div>

    <div id="searchBox"><?php echo $search_output; ?></div>    

我不能像$search_output变量一样回显结果吗?

4

1 回答 1

0

采用

<?php  if(isset($_SESSION['error'])) {echo $_SESSION['error']; unset($_SESSION['error']);} ?> 
<?php  if(isset($_SESSION['count'])) {echo ($_SESSION['count']); unset($_SESSION['count']);} ?> 
于 2013-04-06T09:51:15.587 回答