dzwestwindsor Posted August 31, 2010 Share Posted August 31, 2010 Hello! I need a while loop that renders out part of my "header" redirect block. <?php header ('Location: /mylocation?' /////this is where the header starts. however, for the rest of the header, it needs to be dynamic $counter=1; //I need to define some variables while (babababa) // and I need a while loop that renders out stuff for the header. { Renders out stuff for the header } ) // and then finally i close the "header" ?> However, apparently.. it's yelling at me for having dynamic stuff within the header. Parse error: syntax error, unexpected T_WHILE in /var/www/ars/includes/common.inc(1699) : eval()'d code on line 18 So.... how would I put something dynamic, like a while loop or variables, within the "header" redirect block? Thanks folks! Sorry if this is a bad question xD Quote Link to comment https://forums.phpfreaks.com/topic/212194-do-an-operation-within-a-header/ Share on other sites More sharing options...
Alex Posted August 31, 2010 Share Posted August 31, 2010 You can't do it like that. Instead you can create the string for header() beforehand and then simply pass it to header() afterwards. Quote Link to comment https://forums.phpfreaks.com/topic/212194-do-an-operation-within-a-header/#findComment-1105706 Share on other sites More sharing options...
freelance84 Posted August 31, 2010 Share Posted August 31, 2010 you code just put the value of the header into a variable. $header="location:http://www......"; header ("$header"); exit(); Quote Link to comment https://forums.phpfreaks.com/topic/212194-do-an-operation-within-a-header/#findComment-1105707 Share on other sites More sharing options...
dzwestwindsor Posted August 31, 2010 Author Share Posted August 31, 2010 Thank you guys! It worked At first, I was afraid to do it like that, because I thought that the "header" had to be the first thing in the document. But I guess not? Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/212194-do-an-operation-within-a-header/#findComment-1105765 Share on other sites More sharing options...
Alex Posted August 31, 2010 Share Posted August 31, 2010 What I think you're referring to is the fact that you can't send any headers after there is any output. Quote Link to comment https://forums.phpfreaks.com/topic/212194-do-an-operation-within-a-header/#findComment-1105776 Share on other sites More sharing options...
dzwestwindsor Posted August 31, 2010 Author Share Posted August 31, 2010 Gotcha. Marked as Solved thanks Quote Link to comment https://forums.phpfreaks.com/topic/212194-do-an-operation-within-a-header/#findComment-1105777 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.