0
如何解決這個未定義的偏移量錯誤。php - 未定義的偏移量
我得到:234
Undefined offset 0 - 44, on line 234.
行看起來是這樣的:
$mysql['invo_mysql_where'] .= ($x > 0 ? " OR " : '')."`id` = {$mysql['inactive'][$x]}";
代碼的整個部分,看起來是這樣的:
shuffle($mysql['inactive']);
for($x = 0, $l = $mysql['inactive_amount']; $x < $l; $x++){
$mysql['invo_mysql_where'] .= ($x > 0 ? " OR " : '')."`id` = {$mysql['inactive'][$x]}";
}
$mysql_inactive
:
$mysql['inactive'] = array();
if($ile == 10){
$mysql['inactive_amount'] = mt_rand(0, 1);
} else if($ile == 20){
$mysql['inactive_amount'] = mt_rand(0, 2);
} else if($ile == 30){
$mysql['inactive_amount'] = mt_rand(0, 3);
} else if($ile == 40){
$mysql['inactive_amount'] = mt_rand(0, 4);
} else if($ile == 50){
$mysql['inactive_amount'] = mt_rand(0, 4);
} else if($ile == 60){
$mysql['inactive_amount'] = mt_rand(1, 3);
} else if($ile == 70){
$mysql['inactive_amount'] = mt_rand(2, 3);
} else if($ile == 80){
$mysql['inactive_amount'] = mt_rand(3, 4);
} else if($ile == 90){
$mysql['inactive_amount'] = mt_rand(4, 4);
} else if($ile == 100){
$mysql['inactive_amount'] = mt_rand(5, 5);
} else if($ile == 200){
$mysql['inactive_amount'] = mt_rand(6, 5);
} else {
$mysql['inactive_amount'] = mt_rand(20, 50);
}
$mysql['invo_mysql_where'] = '';
什麼是'$ mysql ['inactive']'?看起來它不是一個數組,或者它是空的。 – BenM
再次檢查我的問題;我已經更新它並添加了$ mysql ['inactive']; – oliverbj
這是一個空白的數組,但你試圖訪問索引? – BenM