Note that there are some explanatory texts on larger screens.

plurals
  1. POfatal error is causing no results to appear (Mysqli)
    primarykey
    data
    text
    <p>I am getting this error in my script which I think is causing the search bar not to work:</p> <blockquote> <p>Fatal error: Call to a member function bind_param() on a non-object in /web/stud/xxx/Mobile_app/previousquestions.php on line 89.</p> </blockquote> <p>The line it is pointing to is this line:</p> <pre><code>$stmt-&gt;bind_param("s",$each); </code></pre> <p>What needs to be done in order to fix this error? At the moment the error is causing no results to appear after the user has submitted the content within the search bar.</p> <pre><code> &lt;?php //connect to db $questioncontent = (isset($_POST['questioncontent'])) ? $_POST['questioncontent'] : ''; ?&gt; &lt;?php if (isset($_GET['searchQuestion'])) { $searchquestion = $questioncontent; $terms = explode(" ", $searchquestion); $parameters = array(); $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 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 "; $i=0; foreach ($terms as $each) { $i++; if ($i == 1){ $questionquery .= "q.QuestionContent LIKE ?"; } else { $questionquery .= "OR q.QuestionContent LIKE ?"; } } $questionquery .= "GROUP BY q.QuestionId, q.SessionId ORDER BY "; $i = 0; foreach ($terms as $each) { $i++; if ($i != 1) $questionquery .= "+"; $questionquery .= "IF(q.QuestionContent LIKE ?,1,0)"; } $questionquery .= " DESC "; $stmt=$mysqli-&gt;prepare($questionquery); $parameters[] = ($each) $stmt-&gt;execute($parameters); $stmt-&gt;bind_result($dbQuestionId,$dbQuestionContent,$dbOptionType,$dbNoofAnswers,$dbAnswer,$dbReplyType,$dbQuestionMarks); $questionnum = $stmt-&gt;num_rows(); } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload