2017-01-14 71 views
1

你好我有問題的陣列。我想數組保存到表,但我收到此:array ||非法抵消類型

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

謝謝

回答

2

問題是,你正在使用數組作爲新數組的鍵。 [..]是定義新數組的簡短方法。如果你想要數字鍵,就去除周圍的圓括號。

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