下面的代碼顯示一個錯誤UNDEFINED偏移:2(線22,28,29)
「未定義偏移:2」 上線22,28,和29
$sql = "SELECT email FROM CommercialEmails WHERE dripid = 1 AND sent='a'";
if ($resultsd1 = mysqli_query($conn, $sql)) {
$affectedrows = mysqli_num_rows($resultsd1);
while ($row = mysqli_fetch_row($resultsd1)){
$results = $row[0];
global $results;
}
}
$broken = explode(' ', $results);
$hi = 0;
$hello = 0;
a:
/**Line 22 **/ if (substr($broken[$hi], -4) == "com," && $broken[$hi] == "qwert"){
$hey[$hi] = $broken[$hi];
$hello++;
}
If(substr($broken[$hi], -4) !== "com,"){ // line 28
$hey[$hi] = $broken[$hi]; //Line 29
}
$hi++;
if ($hi == $affectedrows){
if (!isset($hey)){
echo "There are no emails";
} else {
foreach($hey as $key => $value){
echo $value;
}
echo $hey;
}
}else{
goto a;
}
太棒了!您的錯誤檢查正在工作!你看了看那些爲什麼他們未定義? –
22,28和29的行號在代碼 – tmello01
中註釋爲什麼你在'globalling'$ results'?在循環之前初始化它'$ results ='';''。 – frz3993