Jump to content

Recommended Posts

:'(

Hey guys! Merry Christmas!!!!

Here's my problem.

I have a script where I use the code

include("pagerefresh.php");

where pagerefresh.php is

<?php
    $page = $_SERVER['PHP_SELF']; 
        $sec = "0"; 
	header("Refresh: $sec; url=$page");
?>

 

I use the include function several times on the page and everything's cool with it. But once I put this:

 

<html>
<head>
<title>Title</title>
<script type="text/javascript">
<?php 
some mysql function
include("timecounter.js"); 
?>
</script>
</head> 

 

in the page, the following error pops out whenever I use some of the form functions in the page.

I read the php.net manuals and discovered that the include part should come before

 

Warning: Cannot modify header information - headers already sent by (output started at D:\Hosting\rrr\html\rrr\rrr\rrr.php:191) in D:\Hosting\rrr\html\rrr\rrr\pagerefresh.php on line 4

 

Oh, and I also put the javascript code directly into the page, without the include function, the same results pop out. :/ . Though I suspect that it is immaterial here, the javascript code is:

var month = '<?php echo "$cmonth"; ?>'; // 1 through 12 or '*' within the next month, '0' for the current month m
var day = '<?php echo "$cday"; ?>';   // day of month or + day offset d
var dow = 0;     // day of week sun=1 sat=7 or 0 for whatever day it falls on 
var hour = '<?php echo "$chour"; ?>';    // 0 through 23 for the hour of the day H
var min = '<?php echo "$cminute"; ?>';    // 0 through 59 for minutes after the hour i
var tz = -7;     // offset in hours from UTC to your timezone
var lab = 'cd';  // id of the entry on the page where the counter is to be inserted

function start() {displayCountdown(setCountdown(month,day,hour,min,tz),lab);}
loaded(lab,start);

// Countdown Javascript
// copyright 20th April 2005, 1st November 2009 by Stephen Chapman
// permission to use this Javascript on your web page is granted
// provided that all of the code in this script (including these
// comments) is used without any alteration
// you may change the start function if required
var pageLoaded = 0; window.onload = function() {pageLoaded = 1;}
function loaded(i,f) {if (document.getElementById && document.getElementById(i) != null) f(); else if (!pageLoaded) setTimeout('loaded(\''+i+'\','+f+')',100);
}
function setCountdown(month,day,hour,min,tz) {var m = month; if (month=='*') m = 0;  var c = setC(m,day,hour,tz); if (month == '*' && c < 0)  c = setC('*',day,hour,tz); return c;} function setC(month,day,hour,tz) {var toDate = new Date();if (day.substr(0,1) == '+') {var day1 = parseInt(day.substr(1));toDate.setDate(toDate.getDate()+day1);} else{toDate.setDate(day);}if (month == '*')toDate.setMonth(toDate.getMonth() + 1);else if (month > 0) { if (month <= toDate.getMonth())toDate.setFullYear(toDate.getFullYear() + 1);toDate.setMonth(month-1);}
if (dow >0) toDate.setDate(toDate.getDate()+(dow-1-toDate.getDay())%7);
toDate.setHours(hour);toDate.setMinutes(min-(tz*60));toDate.setSeconds(0);var fromDate = new Date();fromDate.setMinutes(fromDate.getMinutes() + fromDate.getTimezoneOffset());var diffDate = new Date(0);diffDate.setMilliseconds(toDate - fromDate);return Math.floor(diffDate.valueOf()/1000);}
function displayCountdown(countdn,cd) {if (countdn < 0) document.getElementById(cd).innerHTML = "Building Completed"; else {var secs = countdn % 60; if (secs < 10) secs = '0'+secs;var countdn1 = (countdn - secs) / 60;var mins = countdn1 % 60; if (mins < 10) mins = '0'+mins;countdn1 = (countdn1 - mins) / 60;var hours = countdn1 % 24;var days = (countdn1 - hours) / 24;document.getElementById(cd).innerHTML = days+' days and '+hours+' : '+mins+' : '+secs;setTimeout('displayCountdown('+(countdn-1)+',\''+cd+'\');',999);}}

 

 

 

Thanks in advance.

And Merry Christmas!!!!!

 

Thauwa

Link to comment
https://forums.phpfreaks.com/topic/222634-page-refresh-errors/
Share on other sites

It seems that the javascript is reloading the page too. :/ . Does it count with php?

Oh and is there any other way to have the page refreshed without using

header();

and the HTML Meta Refresh?

That would solve most of my problems too. :D

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/222634-page-refresh-errors/#findComment-1151349
Share on other sites

Using the header() function will only work if there is no output before it.

 

The following will not work...

Page Content
<?
  if($login != 'true') {
    include('pagerefresh.php');
  }
?>
Page Content

 

The following will work...

<?
  if($login != 'true') {
    include('pagerefresh.php');
  }
?>
Page Content

 

Be careful using the header() function thats all I say :)

 

Regards, Paul.

Link to comment
https://forums.phpfreaks.com/topic/222634-page-refresh-errors/#findComment-1151362
Share on other sites

Thanks, blueskyis and blew.

But the page won't refresh with

die("<metta http-equiv='refresh' content='$sec;url=$page'>");

:/

I believe that it is because I am not using that code in the <head> section of my page. Do correct me if I am wrong.

What I really want to achieve is to reload the page once a form submits data to itself.

All worked well with header(); , but after I inserted the javascript its been showing the error I mentioned above.

 

Someone please help me. :'( . I've been working on this script for weeks and I don't won't all of it to go to waste. :-/ .

I'll really appreciate more help.

 

Thank you for now, and in advance.

Link to comment
https://forums.phpfreaks.com/topic/222634-page-refresh-errors/#findComment-1151393
Share on other sites

Thanks, blueskyis and blew.

But the page won't refresh with

die("<metta http-equiv='refresh' content='$sec;url=$page'>");

:/

I believe that it is because I am not using that code in the <head> section of my page. Do correct me if I am wrong.

What I really want to achieve is to reload the page once a form submits data to itself.

All worked well with header(); , but after I inserted the javascript its been showing the error I mentioned above.

 

Someone please help me. :'( . I've been working on this script for weeks and I don't won't all of it to go to waste. :-/ .

I'll really appreciate more help.

 

Thank you for now, and in advance.

 

this PHP code must be just in the part that your PHP gonna refresh the page, after all the command u made b4...

 

well, i dont know programming in java, so i cant help ya...

 

im sry, but you can try posting it in the java help forums, from another sites...

maybe there, sum1 can help you a little more :)

 

Link to comment
https://forums.phpfreaks.com/topic/222634-page-refresh-errors/#findComment-1151398
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.