Mysqli错误和警告出现在应用程序中

时间:2012-06-25 11:58:55

标签: php mysqli

  

可能重复:
  MySQLI binding params using call_user_func_array

 

我有一个在语句方面正确的查询,因为这是在MYSQL中测试的。但是当试图从mysql切换到使用mysqli时,我似乎无法在搜索成功后获得结果。

我得到2个错误,但是这些错误:

Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'Array' was given in ... on line 78




Fatal error: Call to a member function execute() on a non-object in ... on line 79

我不明白为什么我会收到警告,因为我正在呼叫一个阵列,所以我不知道为什么会出现警告。我猜这个致命的错误会发出警告,但我不确定。

  
<form action="previousquestions.php" method="get">
<p>Search: <input type="text" name="questioncontent" value="<?php echo $questioncontent; ?>" onchange="return trim(this)" /></p>
<p><input id="searchquestion" name="searchQuestion" type="submit" value="Search" /></p>
</form>

        <?php 

        if (isset($_GET['searchQuestion'])) {

        $questioncontent = (isset($_GET['questioncontent'])) ? $_GET['questioncontent'] : '';
        $searchquestion = $questioncontent;
        $terms = explode(" ", $searchquestion);

        $questionquery = "
        SELECT q.QuestionId, q.QuestionContent, o.OptionType, q.NoofAnswers, GROUP_CONCAT(an.Answer ORDER BY an.Answer SEPARATOR ' ') AS Answer, r.ReplyType, q.QuestionMarks, 
        MATCH (q.QuestionContent) AGAINST (? IN NATURAL LANGUAGE MODE) AS score 
        FROM Answer an INNER JOIN Question q ON q.AnswerId = an.AnswerId JOIN Reply r ON q.ReplyId = r.ReplyId JOIN Option_Table o ON q.OptionId = o.OptionId 
        WHERE MATCH (q.QuestionContent) AGAINST (? IN NATURAL LANGUAGE MODE) 
        GROUP BY q.QuestionId, q.SessionId 
        ORDER BY score 
        ";

        $paramTypes = '';
        $params = array();           
        $i=0;

        //loop through each term
        foreach ($terms as $each) {
            $i++;
            $params[] = "%$each%";
            $paramTypes .= "s";
        }


            $stmt=$mysqli->prepare($questionquery);   
var_dump(call_user_func_array(array($stmt, 'bind_param'), array_merge(array($paramTypes), $params)));
            $stmt->execute();
            $stmt->bind_result($dbQuestionContent); 
            $questionnum = $stmt->num_rows();


          if($questionnum ==0){
            echo "<p>Sorry, No Questions were found from this Search</p>";
            }
            else{

              $output = "";
        $output .= "
            <table border='1' id='resulttbl'>
              <tr>
              <th class='questionth'>Question</th>
              </tr>
        ";
                while ($stmt->fetch()) {
        $output .= "
              <tr>
              <td class='questiontd'>{$dbQuestionContent['QuestionContent']}</td>
              </tr>";
                }
                $output .= "        </table>";

                echo $output;

          }

        }

        ?> 

0 个答案:

没有答案