Forum Moderators: coopster
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!
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.
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..... :-(
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.
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.
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