1
AJAX:未定義,偏移和語法錯誤,但代碼被執行正確
...
success: function(data){
console.log(data);
}
position.php
兩個陣列被轉移($ids
$indexes
和),與相等數目的元件。
extract($_POST);
print_r($ids);
print_r($indexes);
for ($i = 0; $i <= count($ids); $i++) {
$stmt = $db->query("UPDATE " . $table . " SET inde = " . $indexes[$i] . " WHERE id = " . $ids[$i]); // this is line 10
}
的代碼正確執行,即按預期的方式更新了所有表數據,但控制檯(上市陣列之後)顯示了一些錯誤:
Array
(
[0] => 25
[1] => 23
[2] => 18
[3] => 26
[4] => 21
)
Array
(
[0] => 0
[1] => 1
[2] => 2
[3] => 3
[4] => 4
)
<b>Notice</b>: Undefined offset: 5 in <b>D:\matria\s02\admin\position.php</b> on line <b>10</b><br />
<b>Fatal error</b>: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064... near 'WHERE id =' at line 1 in D:\matria\s02\admin\position.php:10
任何幫助嗎?
你是魔術師。非常感謝。 – bonaca
不客氣 –