plodos Posted December 18, 2008 Share Posted December 18, 2008 <table> <tr> <td align='left' width='100%' height='15'> <?php if(isset($_GET['wrong_code17'])){ ?> <div style='border:1px solid #990000; background-color:#D70000; color:#FFFFFF; padding:4px; padding-left:6px; width:300px;'> There is no paper to review. <?php } ?> </td> </tr> </table> <?php $opstr=array(); if(!count($opstr)) { header("Location:".$_SERVER["PHP_SELF"]."?wrong_code17=true"); } else { $opstr=implode('<br />', $opstr); } echo $opstr; ?> 1) if $opstr is empty 2) run the header() function! 3) refresh the page with activate the wrong_code17 but it is not working, because HTML codes are installing before the header() I used used ob_start(); ob_end_flush(); for "Warning: Cannot modify header information" but still the page is not show anything what is the alternative of header() if(!count($opstr)) { //header("Location:".$_SERVER["PHP_SELF"]."?wrong_code17=true"); refresh the page with activate the wrong_code17 } how can I refresh the page with activate the wrong_code17 Help me please Quote Link to comment https://forums.phpfreaks.com/topic/137475-solved-header-function-alternative/ Share on other sites More sharing options...
.josh Posted December 18, 2008 Share Posted December 18, 2008 maybe you didn't use ob_xxx right. It's not in your code, so there's no way to tell. Quote Link to comment https://forums.phpfreaks.com/topic/137475-solved-header-function-alternative/#findComment-718433 Share on other sites More sharing options...
plodos Posted December 18, 2008 Author Share Posted December 18, 2008 I dont know how many times I used it :S but i didnt write the posted code. Quote Link to comment https://forums.phpfreaks.com/topic/137475-solved-header-function-alternative/#findComment-718440 Share on other sites More sharing options...
.josh Posted December 18, 2008 Share Posted December 18, 2008 so..you didn't write that code, and you can't even tell me where or how you used ob_start? Did you read the manual entry for ob_start? Quote Link to comment https://forums.phpfreaks.com/topic/137475-solved-header-function-alternative/#findComment-718447 Share on other sites More sharing options...
plodos Posted December 18, 2008 Author Share Posted December 18, 2008 PHPDocument3.php <?php ob_start('wrong_code17'); // also I used ob_start(); ?> <table> <tr> <td align='left' width='100%' height='15'> <?php if(isset($_GET['wrong_code17'])){ ?> <div style='border:1px solid #990000; background-color:#D70000; color:#FFFFFF; padding:4px; padding-left:6px; width:300px;'> There is no paper to review. <?php } ?> </td> </tr> </table> <?php $opstr=array(); if(!count($opstr)) { header("Location:".$_SERVER["PHP_SELF"]."?wrong_code17=true"); } else { $opstr=implode('<br />', $opstr); } echo $opstr; ?> <?php ob_end_flush(); ?> when I click the http://www.aaaa.com/PHPDocument3.php page is trying to refresh after refresh, link is changing http://aaaa.com/PHPDocument3.php?wrong_code17=true and its show nothing... what can be the problem... Quote Link to comment https://forums.phpfreaks.com/topic/137475-solved-header-function-alternative/#findComment-718463 Share on other sites More sharing options...
trq Posted December 18, 2008 Share Posted December 18, 2008 Organise your code so it doesn't output anything prior to calling header(). There is no point attempting to output something if all your going to do is redirect. It makes No sense. Quote Link to comment https://forums.phpfreaks.com/topic/137475-solved-header-function-alternative/#findComment-718470 Share on other sites More sharing options...
plodos Posted December 18, 2008 Author Share Posted December 18, 2008 im using another codes before the header() thats the big problem but i dont how can i organize the codes if(!count($opstr)) { //header("Location:".$_SERVER["PHP_SELF"]."?wrong_code17=true"); refresh the page with activate the wrong_code17 } are there alternative ways to refresh the page and activate with wrong_code17 if the variable is empty, show the error part, i need that:( Quote Link to comment https://forums.phpfreaks.com/topic/137475-solved-header-function-alternative/#findComment-718476 Share on other sites More sharing options...
trq Posted December 18, 2008 Share Posted December 18, 2008 <?php $opstr=array(); if (!count($opstr)) { header("Location:".$_SERVER["PHP_SELF"]."?wrong_code17=true"); } else { ?> <table> <tr> <td align='left' width='100%' height='15'> <?php if (isset($_GET['wrong_code17'])){ ?> <div style='border:1px solid #990000; background-color:#D70000; color:#FFFFFF; padding:4px; padding-left:6px; width:300px;'> There is no paper to review. <?php } $opstr=implode('<br />', $opstr); echo $opstr; } ?> </td> </tr> </table> ps: The $opstr array is always going to be empty according to your logic. Quote Link to comment https://forums.phpfreaks.com/topic/137475-solved-header-function-alternative/#findComment-718485 Share on other sites More sharing options...
plodos Posted December 18, 2008 Author Share Posted December 18, 2008 im sorry but your code is not working, still same problem did you test your code? or I didnt understand what you mean Quote Link to comment https://forums.phpfreaks.com/topic/137475-solved-header-function-alternative/#findComment-718489 Share on other sites More sharing options...
trq Posted December 18, 2008 Share Posted December 18, 2008 No I didn't test the code. What do you meen by not working? That code should no longer throw the header error. As I explained though $opstr is always going to be an empty array in your code. Quote Link to comment https://forums.phpfreaks.com/topic/137475-solved-header-function-alternative/#findComment-718497 Share on other sites More sharing options...
plodos Posted December 18, 2008 Author Share Posted December 18, 2008 you are right "thorpe" i listened to you, and I changed something if(!count($opstr)){ //header("Location:".$_SERVER["PHP_SELF"]."?wrong_code17=true"); $opstr ="<table> <tr> <td align='left' width='100%' height='15'> <div style='border:1px solid #990000; background-color:#D70000; color:#FFFFFF; padding:4px; padding-left:6px; width:300px;'> There is no paper to review. </td> </tr> </table>"; }else{ $opstr=implode('<br />', $opstr); } echo $opstr; it is doing the same job. thanks for everything Quote Link to comment https://forums.phpfreaks.com/topic/137475-solved-header-function-alternative/#findComment-718498 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.