Welcome to WebmasterWorld Guest from 54.162.239.134

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

I Have a Problem All Was Fine then.

Warning: Cannot modify header information - headers already sent

     
3:24 pm on Dec 8, 2008 (gmt 0)

5+ Year Member



Hi

All was fine and then yesterday every site I have done for my sister and I have one with this script all went boo coo crazy.

I keep getting this error on all sites now and as I mentioned every site was fine until yesterday. I get this error on all of them but different subdomain names.......and they have been up and running fine for way over a year.

Warning: Cannot modify header information - headers already sent in /home2/#*$!#*$!/public_html/subdomain/surf.php on line 56

However, I do not see any blank lines or any errors. I have checked and checked and checked until my eyes are so very weary now.

Here is the Code from the surf.php file which it says is giving the problem :

<?php
session_start();
include("vars.php");
include("auth.php");
mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_name);
$res = checkauth();
$usrid = mysql_result($res, 0, "id");
if ($_SESSION['sess_data']['usrid'] != $usrid) {
$_SESSION['sess_data']['cts'] = 0;
$_SESSION['sess_data']['sts'] = 0;
$_SESSION['sess_data']['pgv'] = 0;
$_SESSION['sess_data']['usrid'] = $usrid;
}
$res = mysql_query("select value from adminprops where field='negact'");
$_SESSION['sess_data']['negact'] = mysql_result($res, 0, "value");
$res = mysql_query("select value from adminprops where field='reftim'");
$_SESSION['sess_data']['reftim'] = mysql_result($res, 0, "value");
$res = mysql_query("select value from adminprops where field='contex'");
if (mysql_result($res, 0, "value") != 0) {
$_SESSION['sess_data']['contex'] = mysql_result($res, 0, "value");
$res = mysql_query("select value from adminprops where field='contey'");
$_SESSION['sess_data']['contey'] = mysql_result($res, 0, "value");
}
$res = mysql_query("select value from adminprops where field='contcx'");
if (mysql_result($res, 0, "value") != 0) {
$_SESSION['sess_data']['contcx'] = mysql_result($res, 0, "value");
$res = mysql_query("select value from adminprops where field='contcy'");
$_SESSION['sess_data']['contcy'] = mysql_result($res, 0, "value");
}
$res = mysql_query("select minmax from user where id=$usrid");
$rate = mysql_result($res, 0, "minmax");
$_SESSION['sess_data']['mmax'] = $rate;
switch($rate) {
case 1:
$rate = 'ratemin';
break;
case 0:
$rate = 'ratemax';
break;
default:
$rate = 'ratemax';
break;
}
$res = mysql_query("select $rate, ref from acctype, user where acctype.id=user.acctype && user.id=$usrid");
$_SESSION['sess_data']['rate'] = mysql_result($res, 0, $rate);
$_SESSION['sess_data']['ref'] = mysql_result($res, 0, "ref");
$_SESSION['sess_data']['surfing'] = rand(9999, 9999999999);
$_SESSION['sess_data']['from'] = md5($_SESSION['sess_data']['surfing']);
if ($_GET['next'] == md5($_SESSION['sess_data']['surf_encoder_vals'])) {
$s_bar_url = "surfbar.php?PHPSESSID=" . session_id() . "&vc_val=" . $_GET['next'];
} else {
$s_bar_url = "surfbar.php?PHPSESSID=" . session_id() . "&vc_val=begin&coder=". md5($_SESSION['sess_data']['from']);
}
flush();
header("Cache-control: private");
echo("<html>\n<head>\n<title>$title: Surf</title>\n<link rel=stylesheet type=text/css href=$self_url" . "style.css>\n</head>\n<frameset rows=$bar_height,* border=0><frame marginheight=0 marginwidth=0 scrolling=no noresize border=0 src=\"$s_bar_url\"><frame marginheight=0 marginwidth=0 scrolling=auto noresize border=0 src=/target.php></frameset>\n</html>");
mysql_close;
exit;
?>

Can someone Please let me know what the problem is because I sure don't see one. Help!

1:32 am on Dec 9, 2008 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member




header("Cache-control: private");

This is the line that's causing the problem. You have to make sure that nothing was sent to the browser before this call, that include HTML as well as whitespace characters.

6:00 am on Dec 9, 2008 (gmt 0)

5+ Year Member



Hi,
Thanks for the reply, so I need to take that whole line out?
Or, just the word private?

I just don't understand though never had a problem before now, weird.... LOL :-)

Thanks

6:07 am on Dec 9, 2008 (gmt 0)

5+ Year Member



Hi Again,

Ok this file I am pasting here now is the Original File which I worked with and purchased and have been using for way over a year and it has the same thing and never gave a problem :

<?php
session_start();
include("vars.php");
include("auth.php");
mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_name);
$res = checkauth();
$usrid = mysql_result($res, 0, "id");
if ($_SESSION['sess_data']['usrid'] != $usrid) {
$_SESSION['sess_data']['cts'] = 0;
$_SESSION['sess_data']['sts'] = 0;
$_SESSION['sess_data']['pgv'] = 0;
$_SESSION['sess_data']['usrid'] = $usrid;
}
$res = mysql_query("select value from adminprops where field='negact'");
$_SESSION['sess_data']['negact'] = mysql_result($res, 0, "value");
$res = mysql_query("select value from adminprops where field='reftim'");
$_SESSION['sess_data']['reftim'] = mysql_result($res, 0, "value");
$res = mysql_query("select value from adminprops where field='contex'");
if (mysql_result($res, 0, "value") != 0) {
$_SESSION['sess_data']['contex'] = mysql_result($res, 0, "value");
$res = mysql_query("select value from adminprops where field='contey'");
$_SESSION['sess_data']['contey'] = mysql_result($res, 0, "value");
}
$res = mysql_query("select value from adminprops where field='contcx'");
if (mysql_result($res, 0, "value") != 0) {
$_SESSION['sess_data']['contcx'] = mysql_result($res, 0, "value");
$res = mysql_query("select value from adminprops where field='contcy'");
$_SESSION['sess_data']['contcy'] = mysql_result($res, 0, "value");
}
$res = mysql_query("select minmax from user where id=$usrid");
$rate = mysql_result($res, 0, "minmax");
$_SESSION['sess_data']['mmax'] = $rate;
switch($rate) {
case 1:
$rate = 'ratemin';
break;
case 0:
$rate = 'ratemax';
break;
default:
$rate = 'ratemax';
break;
}
$res = mysql_query("select $rate, ref from acctype, user where acctype.id=user.acctype && user.id=$usrid");
$_SESSION['sess_data']['rate'] = mysql_result($res, 0, $rate);
$_SESSION['sess_data']['ref'] = mysql_result($res, 0, "ref");
$_SESSION['sess_data']['surfing'] = rand(9999, 9999999999);
$_SESSION['sess_data']['from'] = md5($_SESSION['sess_data']['surfing']);
if ($_GET['next'] == md5($_SESSION['sess_data']['surf_encoder_vals'])) {
$s_bar_url = "surfbar.php?PHPSESSID=" . session_id() . "&vc_val=" . $_GET['next'];
} else {
$s_bar_url = "surfbar.php?PHPSESSID=" . session_id() . "&vc_val=begin&coder=". md5($_SESSION['sess_data']['from']);
}
flush();
header("Cache-control: private");
echo("<html>\n<head>\n<title>$title: Surf</title>\n<link rel=stylesheet type=text/css href=$self_url" . "style.css>\n</head>\n<frameset rows=$bar_height,* border=0><frame marginheight=0 marginwidth=0 scrolling=no noresize border=0 src=\"$s_bar_url\"><frame marginheight=0 marginwidth=0 scrolling=auto noresize border=0 src=/target.php></frameset>\n</html>");
mysql_close;
exit;
?>

So why would it now, it is so very strange..... :-(

6:07 am on Dec 9, 2008 (gmt 0)

5+ Year Member



Hi Again,

Also, I checked the other files which were backups of the sites I have made with this script and they all have same thing, can someone tell me why all the sudden it would or have a problem with the header cache private?

Thanks

7:43 am on Dec 9, 2008 (gmt 0)

5+ Year Member



hi there,

are you sure all your sql queries don't output an error message? you just throw them without any error checking so it wouldn't hurt to do that cleaner !

try adding this at the very least, for each single sql call you do:

<?php
$result = mysql_query('SELECT * WHERE 1=1');
if (!$result) {
die('SQL ERROR : ' . mysql_error());
}

?>

Anyway, this message you get is a WARNING, not a FATAL ERROR. The sudden change can be caused by the server admin changing the error reporting to a more verbose mode (outputting warnings, notices and not only errors as before). This error you're getting typically happens because something is sent to be rendered on the browser too early in your script. Removing the header("....:private") would remove the warning display, but not the exact cause, so i say it again: check your sql queries and include some error checking.

7:04 pm on Dec 9, 2008 (gmt 0)

5+ Year Member



Hi

Thanks for your response, but I have always been scared to mess inside the mysql files, LOL. I look in them and see if I see any type of code which wasnt there before but actually making changes, that scares me to witts......heheheheeee. But I will try and see if I can do as you mentioned though thanks so much, will let ya know the outcome.

12:51 am on Dec 12, 2008 (gmt 0)

5+ Year Member



Hi
Now since I went by some advice in my other posting, I am now getting this error ? Any ideas?

Warning: Cannot modify header information - headers already sent in /home/xpepf/public_html/#*$!xx/logout.php on line 7

Now I removed the flush() in the posts mentioned before and the surfing works great now, but now I have the above problem now since I removed the flush() from line 56 in the previous posts.

Help

4:21 am on Dec 12, 2008 (gmt 0)

10+ Year Member



check the files that are being included in lines 2 and 3
include("vars.php");
include("auth.php");

make sure that there are no whitespaces after the "?>" at end of the files

12:41 am on Dec 16, 2008 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Or try using something like the excellent Live HTTP Headers-Addon for Firefox so you can see what HTTP-Headers are actually sent to the browser and how the content starts. maybe that'll give you clue what's happening where.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month