jmr3460 Posted June 12, 2009 Share Posted June 12, 2009 I have been working on this counter and as long as I check it from my machines it seems to work just fine. I called my brother and ask him to look at the page and he saw a warning. Can not modify header already started on line setcookie();. Once the warning is set for him the warning starts on my machines. If I save as with the same name and upload the save as file the warning leaves. Why would this do this? Can anyone see something I don't see? This is the code: <?php include("dbin.php"); $ip = getenv('REMOTE_ADDR'); $date = date("M-d-Y h:i:s", time()+3600); $table = "home"; $browser = $_SERVER['HTTP_USER_AGENT']; //a defined array with a list of bots in it, defined as $bot include("botlist.php"); if (ereg($browser, $bot)) { exit(); } else{ if (!isset($_COOKIE['clean'])) { setcookie("clean","cleantime",time()+7200,"/"); mysql_connect($host, $user, $pass); mysql_select_db($database) or die(mysql_error()); mysql_query("INSERT INTO $table values('id','$ip','$date','$browser')") or die(mysql_error()); $data = mysql_query("SELECT id FROM home ORDER BY id DESC LIMIT 1;"); $info = mysql_fetch_array($data); $count = $info['id']; } else { mysql_connect($host, $user, $pass); mysql_select_db($database) or die(mysql_error()); $data = mysql_query("SELECT id FROM $table ORDER BY id DESC LIMIT 1;"); $info = mysql_fetch_array($data); $count = $info['id']; } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Xxxxxxxx Regional Website</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta name="discription" content="XX"/> <meta name="keywords" content="xx xxxxxxxxx xxxxxxxxx xxxxxxx "/> <meta name="Robots" content="All"/> <meta name="revisit-after" content="30 days"/> <meta name="author" content="Xxxxx Xxxxxxx"/> <link rel="stylesheet" type="text/css" href="css/arscna2.css"> </head> <body class="oneColElsCtrHdr"> <div id="container"> <div id="header"> <center><?php include ("menu.html"); ?></center> </div><!--End of Header --> <div id="mainContent"> <h1 style="text-align:center;font-style:italic;">WELCOME</h1> <br/><br/> <p style="text-align:justify;"> This Website is one of the ways we use to carry the message of XX to the addict seeking recovery. It contains information for addicts and professionals about Xxxxxx Xxxxxx in the Region. We hope you find our Website useful and helpful. </p> <br/><br/> <p style="text-align:justify;"> "The therapeutic value of one addict helping another is without parallel." (Basic Text, p. 18) If you are an addict, and chanced across this website, call our <a href="helpline/docs/800FlyerRevised.pdf" target="_blank">Helpline</a>, or come to one of our <a href="meetings/">meetings.</a></p> <br/> <br/> <h1 style="text-align:center;font-style:italic;color:#0000ff;">Attention</h1> <br/> <p style="text-align:justify;color:#0000ff;">We are always working on this website. There is a new form that will add you to a regional Service Informational Service Mailing List. The link for this form is <a href="http://www.xxxxx.org/service/mailingList/">HERE</a>. <br/><br/> We now have a new counter on the site. I think that It will be more secure and more accurate. The only thing about this is we have to start over. At the time of the switch we had around 7800. The new counter will give me a little more information about the people who is visiting our site. One thing I will be able to get is the type of browser visitors are using, this will help me when I test scripts The appearance of webpages are different from browser to browser. I am trying to keep the same look and feel on all browsers. This counter will get the information I use to keep our site looking right. <br/><br/> Also you may add your own events to the Regional Calendar. Your event will have to be approved. This is to insure that non XX events are not added. All you do is go to the calendar and click on the + sign in the the box of the date you wish to add an event in, then fill in the blanks. After you fill in all of the blanks necessary click the save button. That is it. We will approve it as soon as we can. <br/><br/> Also if you have a Flyer that you want to upload you can go to our Contact Page and send us your flyers (One at a time Please). We will look for an activity on the calendar to link to the flyer from the calendar as well as link to the flyer from our Flyer Page. You may also send us your flyers via email to [email protected]. </p> <br/><br/> <hr> <hr> <center> For more information about Xxxxx Xxxxx <br>or other Regions, Areas, and Groups throughout the world, please visit <table border="0" cellpadding="5"><tr> <td><a href="http://www.xx.org" target="_blank"> <img border="0" width="233" height="60" src="../images/xxlogo.gif" alt="XX World Services"></a></td> <td><a href="http://www.xx.org" target="_blank">(http://www.xx.org)</a></td> </tr> <tr align="center"><td> <!--</td> <td><a href="http://www.xx.org/ips/" target="_blank">XX World Services<br>On-line Recovery Literature--></td> </tr></table></center> <hr> <div id="footer"> <?php include ("footer.html"); //where thefile.php is the current file $last_modified = filemtime("index.php"); echo "Last updated:"; echo (date("m/j/y", $last_modified)) . "."; echo " There has been " . $count . " visitors to our site, since 6/7/2009"; ?> <!-- end #footer --></div> <!-- end #mainContent --></div> <!-- end #container --></div> </body> </html> Thanks for any help with this issue. Link to comment https://forums.phpfreaks.com/topic/161895-counter-works-until/ Share on other sites More sharing options...
jxrd Posted June 12, 2009 Share Posted June 12, 2009 Is anything output before you set cookies? I'm guessing the space at the top of the script is due to the way you posted it...it's not actually in the file right? Also, what's in dbin.php? Anything output there? If you really can't find anything you can use ob_start. There's probably something though...also, I remeber I read somewhere...can't remeber where that certain FTP clients upload files in some format that adds white space to the file. Some text editors do this as well. You just need to remove whatever's being output to the browser before cookies are being set. Link to comment https://forums.phpfreaks.com/topic/161895-counter-works-until/#findComment-854182 Share on other sites More sharing options...
jmr3460 Posted June 12, 2009 Author Share Posted June 12, 2009 The warning says that the header started on the line that sets the cookie. Link to comment https://forums.phpfreaks.com/topic/161895-counter-works-until/#findComment-854189 Share on other sites More sharing options...
jmr3460 Posted June 12, 2009 Author Share Posted June 12, 2009 OK I just installed another Programmers Editor and I get the same result. Does anyone see something in this script that would try to start a second header? I am going to post my botlist for a look at it. <?php $bot = array("YandexSomething/1.0", "Baiduspider+(+http://www.baidu.com/search/spider.htm)", "TurnitinBot/2.1 (http://www.turnitin.com/robot/crawlerinfo.html)", "LinkWalker/2.0", "Gigabot/3.0 (http://www.gigablast.com/spider.html)", "Sogou web spider/4.0(+http://www.sogou.com/docs/help/webmasters.htm#07)", "Mozilla/5.0 (compatible; Exabot/3.0; +http://www.exabot.com/go/robot)"); ?> Link to comment https://forums.phpfreaks.com/topic/161895-counter-works-until/#findComment-854196 Share on other sites More sharing options...
haku Posted June 12, 2009 Share Posted June 12, 2009 Remove the whitespace before the <?php tag. Link to comment https://forums.phpfreaks.com/topic/161895-counter-works-until/#findComment-854197 Share on other sites More sharing options...
jxrd Posted June 12, 2009 Share Posted June 12, 2009 Remove the whitespace before the <?php tag. Yeah, I did suggest that. I just assumed it wasn't in the actual file. I'm guessing the space at the top of the script is due to the way you posted it...it's not actually in the file right? Link to comment https://forums.phpfreaks.com/topic/161895-counter-works-until/#findComment-854209 Share on other sites More sharing options...
jmr3460 Posted June 12, 2009 Author Share Posted June 12, 2009 I took out my anti-bot part and the error is gone. I will have to do something else to keep the bots out. Link to comment https://forums.phpfreaks.com/topic/161895-counter-works-until/#findComment-854213 Share on other sites More sharing options...
jxrd Posted June 12, 2009 Share Posted June 12, 2009 What? You took out that one array and it worked? And you can keep out bots with a robots.txt file. Link to comment https://forums.phpfreaks.com/topic/161895-counter-works-until/#findComment-854218 Share on other sites More sharing options...
jmr3460 Posted June 12, 2009 Author Share Posted June 12, 2009 No The warning is not there anymore. I just wanted to developed something to keep the bots from being counted on this counter. The counter works means that the counter was developed first then the anti bot snippet was added. Link to comment https://forums.phpfreaks.com/topic/161895-counter-works-until/#findComment-854221 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.