www.webdeveloper.com
Results 1 to 2 of 2

Thread: How to remove the warning below in mysqli

Hybrid View

  1. #1
    Join Date
    Nov 2011
    Posts
    27

    How to remove the warning below in mysqli

    The problem I have is that it is giving me a warning in mysqli stating this:



    Warning: mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of variables doesn't match number of parameters in prepared statement in ...on line 89

    How can I get rid of the warning?
    Code:
        $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->prepare($questionquery);      
         	$stmt->bind_param('s', $each = '%' . $each . '%');
        	$stmt->execute(); 
        	$stmt->bind_result($dbQuestionId,$dbQuestionContent,$dbOptionType,$dbNoofAnswers,$dbAnswer,$dbReplyType,$dbQuestionMarks); 
        	$questionnum = $stmt->num_rows();
    OUTPUT OF SQL:
    Code:
        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 q.QuestionContent LIKE ? 
        
        GROUP BY q.QuestionId, q.SessionId 
        
        ORDER BY IF(q.QuestionContent LIKE ? ,1,0) DESC

  2. #2
    Join Date
    Apr 2003
    Location
    Rosemount, MN
    Posts
    2,287
    You have two '?' in your query but only one replacement in your bind
    My settings

    Browser :: FireFox 1.5
    Resolution :: 1152x864
    Connection :: Cable Modem 2Mbs

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles