简体   繁体   English

数组|| 非法胶印类型

[英]array || illegal offset type

hello guys i got problem with the arrays. 你好,我对数组有问题。 i want to save array to the table but i receive this : 我想将数组保存到表中,但是我收到了:

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

it show to this code 它显示为此代码

[1] => $value1,
[2] => $value2,
[3] => $value3

this is full of code 这充满了代码

$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);

thank you 谢谢

The problem is, you are using arrays as keys for the new array. 问题是,您将数组用作新数组的键。 [..] is the short way to define a new array. [..]是定义新数组的简短方法。 If you want numeric keys, just get rid of the round brackets around. 如果要使用数字键,只需除去圆括号。

$data_value = Array(
    1 => $value1,
    2 => $value2,
    3 => $value3
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM