MetalSmith Posted January 9, 2010 Share Posted January 9, 2010 Hi all I am trying to get this php page to refresh every 5 seconds on my phone which is an aastra 480i IP desk phone. The code below the header line displays a menu on my phone. That works fine so no need to look at that. I am having trouble getting the refresh line to work. How would I make a header for this script with the header line being used below? The header line is in the correct format but I don't know how to apply it. <?php header("Refresh: 5; url= http://XXX.XXX.XXX.XXX/this-page.php”); $textmenu = "<AastraIPPhoneTextMenu style = \"numbered\">\n"; $textmenu .= "<Title>------- Menu -------</Title>\n"; $textmenu .= "<MenuItem>\n"; $textmenu .= "<Prompt>Directory</Prompt>\n"; $textmenu .= "<URI>http://192.168.1.102/aastra/directory.php</URI>\n"; $textmenu .= "</MenuItem>\n"; $textmenu .= "<SoftKey index = \"1\">\n"; $textmenu .= "<Label>Select</Label>\n"; $textmenu .= "<URI>SoftKey:Select</URI>\n"; $textmenu .= "</SoftKey>\n"; $textmenu .= "<SoftKey index = \"6\">\n"; $textmenu .= "<Label>Exit</Label>\n"; $textmenu .= "<URI>SoftKey:Exit</URI>\n"; $textmenu .= "</SoftKey>\n"; $textmenu .= "</AastraIPPhoneTextMenu>\n"; echo $textmenu; ?> Quote Link to comment https://forums.phpfreaks.com/topic/187841-php-header-help/ Share on other sites More sharing options...
JAY6390 Posted January 9, 2010 Share Posted January 9, 2010 Try it with a meta refresh line in your document head instead http://webdesign.about.com/od/metataglibraries/a/aa080300a.htm Quote Link to comment https://forums.phpfreaks.com/topic/187841-php-header-help/#findComment-991767 Share on other sites More sharing options...
mrMarcus Posted January 9, 2010 Share Posted January 9, 2010 your page doesn't refresh then? what's happening? errors? to point out the obvious, your closing double-quote is incorrect in the header() .. should be " and not ” if you simply want the page to refresh every x seconds, make the correction as i already pointed out and should be fine. unless i'm just not understanding. Quote Link to comment https://forums.phpfreaks.com/topic/187841-php-header-help/#findComment-991768 Share on other sites More sharing options...
MetalSmith Posted January 9, 2010 Author Share Posted January 9, 2010 That quote was a typo I have replaced it with " and same results. My phone display will try to update after 5 seconds but the picture just comes back as an Page Load Error Cannot Display. Going to look at the meta refresh thing now. Quote Link to comment https://forums.phpfreaks.com/topic/187841-php-header-help/#findComment-991775 Share on other sites More sharing options...
mrMarcus Posted January 9, 2010 Share Posted January 9, 2010 that header() will refresh the page every 5 seconds, that's not an issue. you sure 5 seconds is long enough for your phone to load this page? try 10 maybe. why do you want to refresh every 5 seconds? it's just a menu. Quote Link to comment https://forums.phpfreaks.com/topic/187841-php-header-help/#findComment-991781 Share on other sites More sharing options...
MetalSmith Posted January 9, 2010 Author Share Posted January 9, 2010 Well the menu is just an example not to give out to much detail of the real page to be refreshed. The timeout is how often the page is refreshed and not how long it takes to refresh the page. The page loads instantly its just a tiny amount of text. The phone has a default timeout of 45 seconds on all XML pages. I just wanted the user to get to a certain page and have it refresh until he is done with it and then he has to manually close it. The phone manual does not give any examples on how to use it so I am kinda stuck and because its a phone and not a browser this makes things more difficult for posting on forums hehehe. Quote Link to comment https://forums.phpfreaks.com/topic/187841-php-header-help/#findComment-991787 Share on other sites More sharing options...
crabfinger Posted January 9, 2010 Share Posted January 9, 2010 what about this? $start_time = time(); for($i=0;;$i++) { $now_time = time(); $total_time = $now_time - $start_time; if($total_time >= 5) { header('location:' . $_SERVER['REQUEST_URI']); } } EDIT: Make sure to put it at the bottom of your script Quote Link to comment https://forums.phpfreaks.com/topic/187841-php-header-help/#findComment-991794 Share on other sites More sharing options...
MetalSmith Posted January 9, 2010 Author Share Posted January 9, 2010 HAHA STUPID!!! I got it to work! There is a space after the url= which breaks it LOL dumb!! header("Refresh: 5; url= http://XXX.XXX.XXX.XXX/this-page.php"); // No good header("Refresh: 5; url=http://XXX.XXX.XXX.XXX/this-page.php"); // This works Thanks for all the help though!!! Quote Link to comment https://forums.phpfreaks.com/topic/187841-php-header-help/#findComment-991796 Share on other sites More sharing options...
mrMarcus Posted January 9, 2010 Share Posted January 9, 2010 The timeout is how often the page is refreshed and not how long it takes to refresh the page. The page loads instantly its just a tiny amount of text. i understand how the function works. this works, which is why i never pointed out the space earlier: header("Refresh: 5; url= http://www.yahoo.com"); so i don't know what was going on with your code. Quote Link to comment https://forums.phpfreaks.com/topic/187841-php-header-help/#findComment-991805 Share on other sites More sharing options...
oni-kun Posted January 9, 2010 Share Posted January 9, 2010 The timeout is how often the page is refreshed and not how long it takes to refresh the page. The page loads instantly its just a tiny amount of text. i understand how the function works. this works, which is why i never pointed out the space earlier: header("Refresh: 5; url= http://www.yahoo.com"); so i don't know what was going on with your code. But remember, he mentioned it's his phone, so you can safely assume it is less robust at fixing typos as so. Quote Link to comment https://forums.phpfreaks.com/topic/187841-php-header-help/#findComment-991806 Share on other sites More sharing options...
mrMarcus Posted January 9, 2010 Share Posted January 9, 2010 The timeout is how often the page is refreshed and not how long it takes to refresh the page. The page loads instantly its just a tiny amount of text. i understand how the function works. this works, which is why i never pointed out the space earlier: header("Refresh: 5; url= http://www.yahoo.com"); so i don't know what was going on with your code. But remember, he mentioned it's his phone, so you can safely assume it is less robust at fixing typos as so. quite true. point taken. Quote Link to comment https://forums.phpfreaks.com/topic/187841-php-header-help/#findComment-991807 Share on other sites More sharing options...
MetalSmith Posted January 9, 2010 Author Share Posted January 9, 2010 Aagin thanks for all the help! One quick follow up question. Can you pass variables with a header? header("Refresh: 15; url=http://192.168.1.102/aastra/details.php?bridge=1"); I have a GET command on the page as well: $bridge = "{$_GET['bridge']}"; Quote Link to comment https://forums.phpfreaks.com/topic/187841-php-header-help/#findComment-991817 Share on other sites More sharing options...
MetalSmith Posted January 9, 2010 Author Share Posted January 9, 2010 Yea it does I got it to pass them. HEHE Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/187841-php-header-help/#findComment-991821 Share on other sites More sharing options...
crabfinger Posted January 9, 2010 Share Posted January 9, 2010 also if you want to refresh the exact page you can do header("Refresh: 15; url=$_SERVER['REQUEST_URI']"); Which will have the full uri including the query string. Quote Link to comment https://forums.phpfreaks.com/topic/187841-php-header-help/#findComment-991844 Share on other sites More sharing options...
mrMarcus Posted January 9, 2010 Share Posted January 9, 2010 $bridge = "{$_GET['bridge']}"; you do not need to surround $_GET['bridge'] with "" .. this is easier: $bridge = $_GET['bridge']; the {} used are used to "explicitly specify the end of the name.", and are not of mandatory usage within HEREDOC and NOWDOC syntax's. Quote Link to comment https://forums.phpfreaks.com/topic/187841-php-header-help/#findComment-991846 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.