你好,伙计们,我的阵列有问题。我想将数组保存到表中,但收到以下消息:
illegal offset type in C:\xampp\htdocs\app-mt\php\proses-edit-aplikasi.php on line 13
illegal offset type in C:\xampp\htdocs\app-mt\php\proses-edit-aplikasi.php on line 14
illegal offset type in C:\xampp\htdocs\app-mt\php\proses-edit-aplikasi.php on line 15
它显示了这个代码
[1] => $value1,
[2] => $value2,
[3] => $value3
这满是密码
$value1 = $_POST['value1'];
$value2 = $_POST['value2'];
$value3 = $_POST['value3'];
$data_value = Array(
[1] => $value1,
[2] => $value2,
[3] => $value3
);
$array_value = serialize($data_value);
$query = "UPDATE maintenance
SET pic = '$pic',
application_name = '$nama',
maintenance_date = '$tanggal',
entry_by = '$pictrans'
WHERE maintenance_id = '$id'";
$query2 = "UPDATE INTO maintenance_detail
SET value = '$array_value'
WHERE maintenance_detail_id = '$id'";
$hasil = mysqli_query($db, $query);
$hasil2 = mysqli_query($db, $query2);
谢谢您
最佳答案
问题是,您使用数组作为新数组的键。[..]
是定义新数组的捷径。如果你想要数字键,就去掉圆括号。
$data_value = Array(
1 => $value1,
2 => $value2,
3 => $value3
);
关于php - 数组||非法胶印类型,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41653274/