Jump to content

Headers error


Gruzin

Recommended Posts

Hi guys, I know it sounds dumb, but I can not get rid of this damn header error:

 

<?php
require ('config.php');

if(!isset($_COOKIE['user'])){
$user = $_SERVER['REMOTE_ADDR'];
$date = date('m-Y');
$sql = mysql_query("INSERT INTO `aid_counter` (`user`, `date`, `id`) VALUES ('$user', '$date', NULL);");

setcookie("user",$user,time()+2678400); // 1 month
}
?>

 

This is a simple counter script wich I want to include somewhere , but I recieve the following error:

 

Warning: Cannot modify header information - headers already sent by (output started at /www/cida.ge/doc/index.php:42) in /www/cida.ge/doc/admin/counter.php on line 9

 

Thanks for any help,

george

Link to comment
Share on other sites

1) Make sure you don't have any output in config.php.

2) Make sure you don't have any line-breaks / spaces before the opening "<?php" in this script or in config.php. Also make sure you don't have any line-breaks / spaces after the closing "?>" in config.php

 

Orio.

 

Link to comment
Share on other sites

Thanks Orio,

 

here is my config.php:

 

<?php
// database connection
$con = mysql_connect("localhost","XXX","XXX");
if(!$con){
  die('Error:'.mysql_error());
  }
$db = mysql_select_db("cida_ge",$con);
if(!$db){
  die('Could not select database:'.mysql_error());
  }
$u = "http://www.cida.ge"; // edit your domain here, without backslash
?>

Link to comment
Share on other sites

me and u both have same error.. and when i comment out the setcookie.. the error goes away but WTF?? no setcookie means no clientside saving really angers me off.. I yet to have solve this problem and the thing is my script worked before I have no idea what i did to it.

Link to comment
Share on other sites

headers already sent by (output started at /www/cida.ge/doc/index.php:42

 

What is line 42?

 

<link href="css/style.css" rel="stylesheet" type="text/css">

 

line 42 is not php...

 

remove the linebreak spaces whatever after the ?> in ALLL INCLUDES and REQUIRES

 

What do u mean by that?

Link to comment
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.