Serenitee Posted August 1, 2010 Share Posted August 1, 2010 It would see my else is being ignored, and it's a bit confusing. There is only 1 row in my current test array, and $craftItAmt == 'm' at the moment. The result "should" be that it goes into the else and moves off to the error page with code e041 - but instead it is ignoring the else, and returning error page with e001 as the array is empty. I'm stumped, if I change the redirect to an echo, it will echo. If I change the redirect to a variable set (ie: $intCheck = 'yes' and then place an if $intCheck == 'yes' go to the header.. it is still ignored. $toCraft = array(); foreach($clean as $craftIt => $craftItAmt) {if($craftItAmt != '') {if(is_numeric($craftItAmt)) {$toCraft[str_replace('_', ' ', $craftIt)] = $craftItAmt;} else {header('Location: /crafted/error.php?Code=e041');}} } $toCraftCounter = count($toCraft); if($toCraftCounter == 0) {header('Location: /crafted/error.php?Code=e001');} tia Link to comment https://forums.phpfreaks.com/topic/209482-else-being-ignored/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 1, 2010 Share Posted August 1, 2010 You need exit; statements after each header() redirect to prevent the remainder of the code on the page from executing while the browser requests the new URL that is in the Location: header. The last header() your code is outputting WINS. Link to comment https://forums.phpfreaks.com/topic/209482-else-being-ignored/#findComment-1093782 Share on other sites More sharing options...
Serenitee Posted August 1, 2010 Author Share Posted August 1, 2010 I knew it had to be something annoyingly easy. Tyvm - I thought it was the first header that wins (and further attempts provided error). Working perfectly now of course! Link to comment https://forums.phpfreaks.com/topic/209482-else-being-ignored/#findComment-1093783 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.