2011-04-03 64 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; 
    } 
相关问题