unistake Posted January 15, 2016 Share Posted January 15, 2016 (edited) Hi guys, I have this script I am running, http://pastebin.com/NR1A03hY, works perfectly and does everything I need it to do. The only thing is the redirect at the bottom of the script does not work if line 40 is true. I think I have a problem with my foreach loop and the if statements in-between. Please can someone check, I have no idea on this one! Edit: in the pastebin the redirect is striked out as i was problem solving it. Of course i would not strike it out once its back working! Thanks Edited January 15, 2016 by unistake Quote Link to comment https://forums.phpfreaks.com/topic/300357-foreach-breakout/ Share on other sites More sharing options...
unistake Posted January 15, 2016 Author Share Posted January 15, 2016 anybody? Quote Link to comment https://forums.phpfreaks.com/topic/300357-foreach-breakout/#findComment-1529708 Share on other sites More sharing options...
unistake Posted January 15, 2016 Author Share Posted January 15, 2016 basically once the script has run through every line, I want it to redirect. How can I do this? Quote Link to comment https://forums.phpfreaks.com/topic/300357-foreach-breakout/#findComment-1529712 Share on other sites More sharing options...
QuickOldCar Posted January 15, 2016 Share Posted January 15, 2016 (edited) If this was written all the processing code up top and display output all below could have used header() prior to any output. You can add a meta refresh in the place you have header() commented out. echo "<meta http-equiv='refresh' content='5;URL='members_roster.php' />"; Edited January 15, 2016 by QuickOldCar Quote Link to comment https://forums.phpfreaks.com/topic/300357-foreach-breakout/#findComment-1529714 Share on other sites More sharing options...
unistake Posted January 15, 2016 Author Share Posted January 15, 2016 Thanks, This page is purely a php processing page. The user sends data too it from a previous page, and once that data is processed I want it to redirect. Quote Link to comment https://forums.phpfreaks.com/topic/300357-foreach-breakout/#findComment-1529716 Share on other sites More sharing options...
Muddy_Funster Posted January 15, 2016 Share Posted January 15, 2016 Define "Not Working" please. Quote Link to comment https://forums.phpfreaks.com/topic/300357-foreach-breakout/#findComment-1529718 Share on other sites More sharing options...
unistake Posted January 15, 2016 Author Share Posted January 15, 2016 Muddy_Funster, The script processes the information as needed however after each $line has been processed in the foreach statement, I want all ending results to redirect to header("Location: members_roster.php"); Quote Link to comment https://forums.phpfreaks.com/topic/300357-foreach-breakout/#findComment-1529719 Share on other sites More sharing options...
Muddy_Funster Posted January 15, 2016 Share Posted January 15, 2016 OK, so that covers "what should happen", what I'm asking is "what is actually happening"? Are there any error messages? does it redirect to the wrong location? does it give an empty output? have you got error checking and display errors at full and turned on? At what point does it break down? are the DB queries firing ok? The more verbose you can be with the problem the quicker we can help you find a solution. Quote Link to comment https://forums.phpfreaks.com/topic/300357-foreach-breakout/#findComment-1529723 Share on other sites More sharing options...
unistake Posted January 15, 2016 Author Share Posted January 15, 2016 Ok, at the moment it is just displaying a blank white page and no redirect is happening. The queries fire absolutely fine from what i can see in my database. The code seems to break down at the end of the code on line 84. If the code satisfies the if statement on line 91 the code runs and redirects exactly as it should finishing with the exit on line 128. Quote Link to comment https://forums.phpfreaks.com/topic/300357-foreach-breakout/#findComment-1529725 Share on other sites More sharing options...
Muddy_Funster Posted January 15, 2016 Share Posted January 15, 2016 Alright and where are we with display errors and error reporting? If you're using a hosting provider they commonly have error logging done to a file rather than the screen, which makes sense for public facing websites, but isn't as handy for development work Quote Link to comment https://forums.phpfreaks.com/topic/300357-foreach-breakout/#findComment-1529727 Share on other sites More sharing options...
unistake Posted January 15, 2016 Author Share Posted January 15, 2016 I've just contacted the host provider. should be turned on in 10mins Quote Link to comment https://forums.phpfreaks.com/topic/300357-foreach-breakout/#findComment-1529728 Share on other sites More sharing options...
Muddy_Funster Posted January 15, 2016 Share Posted January 15, 2016 Did you add the echo after you found that the header call wasn't working or was it always there? echo 'Your roster has been updated! <a href="members_roster.php">Click here</a> to return to your roster.'; //header("Location: members_roster.php"); exit(); Quote Link to comment https://forums.phpfreaks.com/topic/300357-foreach-breakout/#findComment-1529729 Share on other sites More sharing options...
unistake Posted January 15, 2016 Author Share Posted January 15, 2016 i added it after to see if it was echoing. Quote Link to comment https://forums.phpfreaks.com/topic/300357-foreach-breakout/#findComment-1529730 Share on other sites More sharing options...
unistake Posted January 15, 2016 Author Share Posted January 15, 2016 there are not any errors being displayed on that page. I have errors that have just popped up on others. Quote Link to comment https://forums.phpfreaks.com/topic/300357-foreach-breakout/#findComment-1529734 Share on other sites More sharing options...
Muddy_Funster Posted January 15, 2016 Share Posted January 15, 2016 take the echo out and run the page with the header() again, see if there are any errors then. 1 Quote Link to comment https://forums.phpfreaks.com/topic/300357-foreach-breakout/#findComment-1529735 Share on other sites More sharing options...
unistake Posted January 15, 2016 Author Share Posted January 15, 2016 (edited) no errors on the page at all showng in the display_errors or error reports. Edited January 15, 2016 by unistake Quote Link to comment https://forums.phpfreaks.com/topic/300357-foreach-breakout/#findComment-1529739 Share on other sites More sharing options...
Muddy_Funster Posted January 15, 2016 Share Posted January 15, 2016 Well if there's no errors the next thing to try would be to use the full URL in the header call, rather than the referential URL header('Location: http://yoursite.com/folder/members_roster.php'); Quote Link to comment https://forums.phpfreaks.com/topic/300357-foreach-breakout/#findComment-1529742 Share on other sites More sharing options...
mac_gyver Posted January 15, 2016 Share Posted January 15, 2016 (edited) just to be clear, you are stating that with the echo 'Your roster has been updated ...'; statement in the code and the header() statement commented out, and you are sure the code you are showing us is is the correct and complete code that's being ran on the server, and the rank/crew type is not "Captain" and is not "First Officer", that all you get is a blank page? if so, what does the 'view source' of that blank page in your browser show? also, is there any chance that the blank page you end up on is frontend_login.php or some other page than the one you are showing us the code for? what is the $_SESSION['Code'] value for this case where it isn't working? if is seems like i/we are being skeptical, it's because the symptom you are stating is impossible for the posted code. so, either the code being posted isn't what is being ran or the symptom being reported isn't correct. there's actually a ton of stuff this code is doing that isn't needed and can be greatly simplified, but having nothing to do with the current problem. Edited January 15, 2016 by mac_gyver Quote Link to comment https://forums.phpfreaks.com/topic/300357-foreach-breakout/#findComment-1529751 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.