这里有什么问题?
$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);
错误是:
警告:MysqLi_stmt :: bind_param()[MysqLi-stmt.bind-param]:类型定义字符串中的元素数量与绑定变量的数量不匹配
解决方法:
您没有正确使用该方法,仅查看签名(如the doc pages所示):
bool MysqLi_stmt::bind_param ( string $types , mixed &$var1 [, mixed &$... ] )
第一个参数应该是一个字符串,指示实际参数是什么类型…就您而言,我猜是这样的:
$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);
这就是你想要做的…