homepage Welcome to WebmasterWorld Guest from 54.204.215.209
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe and Support WebmasterWorld
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
I Have a Problem All Was Fine then.
Warning: Cannot modify header information - headers already sent
lordsbaby2007




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

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!

 

eelixduppy




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


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.

lordsbaby2007




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

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

lordsbaby2007




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

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..... :-(

lordsbaby2007




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

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

pixeline




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

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.

lordsbaby2007




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

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.

lordsbaby2007




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

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

jezra




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

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

janharders




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

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved