从 PHPExcel 生成数组导入数组到字符串错误
Importing array from PHPExcel producing array to string error
我正在尝试使用 PHPExcel 从导入的数组中填充 table in php。我收到 'producing array to string error in' 错误。我相信这与将数组转换为字符串有关。该错误表明它来自 mysqli_stmt_execute($query_mtcelogARRAY);
行
$mtcelogARRAY = $objPHPExcel->setActiveSheetIndex(2)->rangeToArray('A8:A18');
$num_mtcelog = count($mtcelogARRAY); // Here get total count of row in that Excel sheet
$mtcelogID = $siteNAME.'.'.$Maindate.'.';
for( $i=0; $i<=$num_mtcelog; $i++ ){
$sql_mtcelog = "INSERT INTO `maintenance_log`(`mtcelogID`,`mtcelogTYPE`,`MaintenanceID`) VALUES (?,?,?)";
$query_mtcelogARRAY = mysqli_prepare($link, $sql_mtcelog);
mysqli_stmt_bind_param($query_mtcelogARRAY,"sss", $mtcelogID, $mtcelogARRAY[$i], $MaintenanceID);
mysqli_stmt_execute($query_mtcelogARRAY);
mysqli_stmt_close($query_mtcelogARRAY);
}
var_dump($mtcelogARRAY);
这就是它填充我的 table
的方式
我的数组看起来像这样
非常感谢!
改变
mysqli_stmt_bind_param($query_mtcelogARRAY,"sss", $mtcelogID, $mtcelogARRAY[$i], $MaintenanceID);
到
mysqli_stmt_bind_param($query_mtcelogARRAY,"sss", $mtcelogID, $mtcelogARRAY[$i][0], $MaintenanceID);
我正在尝试使用 PHPExcel 从导入的数组中填充 table in php。我收到 'producing array to string error in' 错误。我相信这与将数组转换为字符串有关。该错误表明它来自 mysqli_stmt_execute($query_mtcelogARRAY);
$mtcelogARRAY = $objPHPExcel->setActiveSheetIndex(2)->rangeToArray('A8:A18');
$num_mtcelog = count($mtcelogARRAY); // Here get total count of row in that Excel sheet
$mtcelogID = $siteNAME.'.'.$Maindate.'.';
for( $i=0; $i<=$num_mtcelog; $i++ ){
$sql_mtcelog = "INSERT INTO `maintenance_log`(`mtcelogID`,`mtcelogTYPE`,`MaintenanceID`) VALUES (?,?,?)";
$query_mtcelogARRAY = mysqli_prepare($link, $sql_mtcelog);
mysqli_stmt_bind_param($query_mtcelogARRAY,"sss", $mtcelogID, $mtcelogARRAY[$i], $MaintenanceID);
mysqli_stmt_execute($query_mtcelogARRAY);
mysqli_stmt_close($query_mtcelogARRAY);
}
var_dump($mtcelogARRAY);
这就是它填充我的 table
的方式我的数组看起来像这样
非常感谢!
改变
mysqli_stmt_bind_param($query_mtcelogARRAY,"sss", $mtcelogID, $mtcelogARRAY[$i], $MaintenanceID);
到
mysqli_stmt_bind_param($query_mtcelogARRAY,"sss", $mtcelogID, $mtcelogARRAY[$i][0], $MaintenanceID);