0

我的代码中有这个错误:

致命错误:无法在第 39 行调用堆栈的 A:\wamp\www\includes\func.inc.php 中重新声明 search_results()(之前在 A:\wamp\www\includes\func.inc.php:4 中声明)

在那个文件中,我有:

<?php

function search_results($keywords){
    $returned_results = array();
    $where = "";

    $keywords = preg_split('/[\s]+/',$keywords);
    $total_keywords = count($keywords);

        foreach($keywords as $key=>$keyword){
            $where .= "`article_content` LIKE '%$keyword%'";
                if($key != ($total_keywords - 1)){
                    $where .= " AND ";
                }
        }

    $results = "SELECT *  FROM `articles` WHERE $where";
    $results_num = ($results = mysql_query($results)) ? mysql_num_rows($results) : 0 ;
    if($results_num === 0){
        return false;
    }
    else{

        while($results_row = mysql_fetch_assoc($results)){
            $returned_results[] = array(

                    'article_title' =>$results_row['article_title'],
                    'article_content' =>$results_row['article_content'],
                    'article_timestamp' =>$results_row['article_timestamp'],
                    'article_id' =>$results_row['article_id']

            );
        }

        return $returned_results;

    }
}
?>

我不知道是什么问题。请帮助我尽快解决此错误!提前致谢

4

2 回答 2

6

问题不在 MYSQL 中,您包含该文件两次。

于 2013-10-08T16:35:42.867 回答
2

使用include_once而不是include.

于 2013-10-08T16:37:12.600 回答