Jump to content

[SOLVED] Header Issue


timmah1

Recommended Posts

I know there is a sticky about this.

 

This is the top of my page, nothing is being passed except the setcookie() at the very top, unless you count the <?php

Why am I constantly getting a header already sent out error?

 

 

<?php
setcookie('aff_ses', session_start());
setcookie('aff_id', $_GET['aff_id']);
setcookie('aff_ip', $_SERVER['REMOTE_ADDR']);
setcookie('aff_ref', $_SERVER['HTTP_REFERER']);

setcookie('longtime', 'nextyear', time() + (60 * 60 * 24 * 365));

$nextYear = time() + (60 * 60 * 24 * 365);
setcookie('visittime', time(), $nextYear);

$referer = preg_replace("/(http:\/\/(.*)\/)[\S]*/", "\\1", $_SERVER['HTTP_REFERER']);
$name = preg_replace("/http:\/\//", "", $referer);

require("config2.php");

$query = "SELECT * FROM affiliates_session WHERE aff_ses  = '".session_id()."' AND aff_id ='". $_COOKIE['aff_id']."'";
	$q = mysql_query($query);
	$numrows = mysql_num_rows($q);

		if($numrows == 0){
				$sql = "INSERT INTO affiliates_session(aff_ses, aff_id, aff_ip, aff_ref, aff_bas) VALUES(
				'".session_id()."',
				'".$_COOKIE['aff_id']."',
				'".$_COOKIE['aff_ip']."',
				'".$_COOKIE['aff_ref']."',
				'".$name."');";
				mysql_query($sql)
				or die("Sorry, there was a problem adding new sponsor<br /> ".mysql_error());

				//$comment = "Info has been inserted<br />";
		}

		else {
		//$comment = "No info inserted<br />";
		}
require("testVals.php");
$current = date("Y-m-d");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN""http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- Start Meta Data -->
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Vegas Sports Picks - Free Sports Picks - Sports Betting Picks</title>
<meta name="title" content="Vegas Sports Picks - Free Sports Picks "> 
<meta name="description" content="<?=$desc1;?>" />
<meta name="keywords" content="<?=$keywords;?>" />
<META name="robots" content="index,follow">
<meta name="verify-v1" content="nVIzcVVxXdW7adyPpAZ0CsuM4QV4s7Ag1kBL088lw/M=" >
<link href="https://secure.vegasdsports.com/main.css" rel="stylesheet" type="text/css" />

 

Another thing, this is running on a secure (SSL) server, does that make a difference?

 

Thanks in advance

Link to comment
Share on other sites

wouldn't this line set a cookie with either true or false on the clients machine, depending on wether or not the session started?

 

setcookie('aff_ses', session_start());

 

Shouldn't you been saving the session id on the clients machine?

 

session_start();

setcookie( 'aff_ses', session_id() );

Link to comment
Share on other sites

Here are the errors

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/vegas/public_html/core/index.php:1) in /home/vegas/public_html/core/index.php on line 2
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/vegas/public_html/core/index.php:1) in /home/vegas/public_html/core/index.php on line 2
Warning: Cannot modify header information - headers already sent by (output started at /home/vegas/public_html/core/index.php:1) in /home/vegas/public_html/core/index.php on line 3
Warning: Cannot modify header information - headers already sent by (output started at /home/vegas/public_html/core/index.php:1) in /home/vegas/public_html/core/index.php on line 4
Warning: Cannot modify header information - headers already sent by (output started at /home/vegas/public_html/core/index.php:1) in /home/vegas/public_html/core/index.php on line 5
Warning: Cannot modify header information - headers already sent by (output started at /home/vegas/public_html/core/index.php:1) in /home/vegas/public_html/core/index.php on line 6
Warning: Cannot modify header information - headers already sent by (output started at /home/vegas/public_html/core/index.php:1) in /home/vegas/public_html/core/index.php on line 8
Warning: Cannot modify header information - headers already sent by (output started at /home/vegas/public_html/core/index.php:1) in /home/vegas/public_html/core/index.php on line 11

 

Here is the code

<?php
session_start();
setcookie('aff_ses', session_id());
setcookie('aff_id', $_GET['aff_id']);
setcookie('aff_ip', $_SERVER['REMOTE_ADDR']);
setcookie('aff_ref', $_SERVER['HTTP_REFERER']);

setcookie('longtime', 'nextyear', time() + (60 * 60 * 24 * 365));

$nextYear = time() + (60 * 60 * 24 * 365);
setcookie('visittime', time(), $nextYear);

$referer = preg_replace("/(http:\/\/(.*)\/)[\S]*/", "\\1", $_SERVER['HTTP_REFERER']);
$name = preg_replace("/http:\/\//", "", $referer);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN""http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- Start Meta Data -->
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Vegas Sports Picks - Free Sports Picks - Sports Betting Picks</title>
<meta name="title" content="Vegas Sports Picks - Free Sports Picks "> 
<meta name="description" content="<?=$desc1;?>" />
<meta name="keywords" content="<?=$keywords;?>" />
<META name="robots" content="index,follow">
<link href="https://secure.vegasdsports.com/main.css" rel="stylesheet" type="text/css" />

 

It shouldn't matter whether this on a SSL or not right?

Link to comment
Share on other sites

If there are no actual characters on line 1 in the file before the <?php tag, that error means that you file has been saved as a Unicode/UTF-8 (or 16) encoded file and the BOM (Byte Order Mark) characters that your editor put at the start of the file are the output that is causing the headers to not work. Save your file as an ANSI/ASCII file or save it as a Unicode/UTF-8 without the BOM.

 

P.S. Output buffering should not be used to solve content/header problems and in this case where the output is coming on line 1 of the file, it won't work anyway.

Link to comment
Share on other sites

PFMaBiSmAd,

I have been using DW for my pages forever, and have never ran into this problem before.

I have always started a new PHP page, and saved it and everything works fine.

 

How do I go about saving the page correctly?

Link to comment
Share on other sites

In the "file save/as" dialog, there should be a choice for what encoding the file is saved as.

 

If there is not a choice to save the file the way you want it, create a new file and copy/paste the contents of the existing file into the new one.

Link to comment
Share on other sites

I don't see an encoding choice, anywhere, and when I create a new file and save it, the same issues happens

 

I checked my preferences, and I see a box for Default Encoding, which is set to Unicode(UTF-8), there is no option for ANSI/ASCII.

 

Also, there is a drop down for Unicode Normalization Form with a checkbox that says Include Unicode Signature (BOM).

 

The choices for the Normailization form are

C (Canonical Decomposition, followed by Canonical Compostion)

D (Canonical Decompostion)

KC (Compatitbility Decomposition, followed by Canonical Compostion)

KD (Compatitbility Decompostion)

Link to comment
Share on other sites

I took all that other stuff out, and am just using this now

<?php
session_start();
require("config.php");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Vegas Sports Picks - Free Sports Picks - Sports Betting Picks</title>
<meta name="title" content="Vegas Sports Picks - Free Sports Picks "> 
<meta name="description" content="<?=$desc1;?>" />
<meta name="keywords" content="<?=$keywords;?>" />
<META name="robots" content="index,follow">
<link href="https://secure.vegasdsports.com/main.css" rel="stylesheet" type="text/css" />

 

And I get this

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/vegas/public_html/core/index.php:1) in /home/vegas/public_html/core/index.php on line 2

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/vegas/public_html/core/index.php:1) in /home/vegas/public_html/core/index.php on line 2

 

I'm going nuts because has never happened before

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.