Jump to content

Recommended Posts

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.