Warning: mysqli_stmt::bind_param()

2019-03-01 02:49发布

问题:

What is the problem here?

$stmt  =$con->prepare("INSERT INTO tcp (capture_order, from_ip, to_ip, from_port, to_port, tcp_length, tcp_stream, tcp_stream_text, tcp_sequence_dec) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");

$stmt->bind_param(   $this->capture_order,$this->from_ip, $this->to_ip,      $this->from_port,$this->to_port,   $this->tcp_length,$this->tcp_stream,     $this->tcp_stream_text, $this->tcp_sequence_dec);

The error is: Warning: mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of elements in type definition string doesn't match number of bind variable

回答1:

You're not using the method properly, just look at the signature (as shown on the doc pages):

bool mysqli_stmt::bind_param ( string $types , mixed &$var1 [, mixed &$... ] )

The first argument should be a string, indicating what types the actual params are... In your case, I'd guess something like:

$stmt->bind_param('issiiiiss', $this->capture_order,$this->from_ip, $this->to_ip,      $this->from_port,$this->to_port,   $this->tcp_length,$this->tcp_stream, $this->tcp_stream_text, $this->tcp_sequence_dec);

Is what you're trying to do...



标签: php mysqli