2011-04-03 39 views
1

我使用mysqli_stmt :: bind_param()時遇到問題。有人能幫我嗎? 警告:mysqli_stmt :: bind_param()[mysqli的-stmt.bind-PARAM]:在類型定義字符串元素數不匹配綁定變量的數...mysqli_stmt :: bind_param()類型定義字符串中元素的數量不匹配編號

我在PHP初學者。由於

public function init($cards,$table,$seats) 
{ 
$operation = $this->operation($table, $seats); 
return $this->insertCards($cards,$operation,count($cards)); 

    }  
public function operation($table, $seats) 
{ 
    $operation = "insert into ".$table."("; 
    $values = "("; 
    for($i = 0; $i<count($seats);$i++) 
    { 
    $operation .= " cardsSeat".$seats[$i].","; 
    $values .= "?,"; 
    } 
    $values .= "?,?,?)"; 
    $operation .= " flop, turn, river) values ".$values; 

    return $operation;   

} 


    public function insertCards($cards, $operation, $x) 
    { 

     $insertCards = $this->spojenie->prepare($operation); 
     $refArray = array(); 
     foreach($cards as $key => $value) $refArray[$key] = &$cards[$key]; 
     call_user_func_array(array($insertCards, 'bind_param'), $refArray); 



     $insertCards->execute(); 
     return true; 

    } 
+1

可能重複的[錯誤時結合PARAMS(PHP)](http://stackoverflow.com/questions/ 5131297 /錯誤 - 當結合-PARAMS-PHP) – deceze 2011-04-03 02:44:12

回答

2

解決

  • 字符串類型( 「SSS ......」);

公共函數insertCards($卡,$操作,$ x)的 {

 $types = ""; 
     foreach($cards as $value) 
      $types .= "s"; 
     $cards = array_merge(array($types),$cards); 
     $insertCards = $this->spojenie->prepare($operation); 
     $refArray = array(); 
     foreach($cards as $key => $value) $refArray[$key] = &$cards[$key]; 
     call_user_func_array(array($insertCards, 'bind_param'), $refArray); 



     $insertCards->execute(); 
     return true; 
    } 
相關問題