mysqli_stmt :: bind_param () Количество элементов в строке определения типа не соответствует номеру - PullRequest
1 голос
/ 03 апреля 2011

У меня проблема с использованием 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 Ответ

2 голосов
/ 03 апреля 2011

Решено

  • типы строк ("sss ...");

публичные функции insertCards ($ cards, $ operation, $ 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;
    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...