Jump to content

Headers aready sent error


andrew_biggart

Recommended Posts

Ok so I know this is a popular error and I've experienced it many times before, but it's driving me crazy and I can't find a solution. So i thought a fresh pair of eyes might be able to shed some light on it.

 

I'm just re-writing this particular piece of code and not changing a great deal. It works fine on the old page, but not on the new one. I haven't changed anything apart from stripping it right back to the basics.

 

I have included my config file at the top of the page.

 


<?php
// Turn php errors on / off
$errors = true;

if($errors){
ini_set('display_errors',1);
error_reporting(E_ALL);
}

// Get the redirect
if(isset($_GET['redirect'])){
$redirect = htmlspecialchars($_GET['redirect']);
}

if(isset($_COOKIE['authcode']) && isset($_COOKIE['userid'])){

// Get the auth code
$authcode = htmlspecialchars($_COOKIE['authcode']);

// Get the user id
$userid = htmlspecialchars($_COOKIE['userid']);

// Check auth code and user id against the database
$sql = "SELECT * FROM staff_newT WHERE staff_id = '$userid' AND staff_authcode = '$authcode'";
$result = mysql_query($sql);
$count = mysql_num_rows($result);

if($count == 1){
echo "Both match <br /><br />";
} else {
echo "Deleted <br /><br />";
// Delete authcode cookie.
setcookie("authcode", "", time() - 3600);

} // Check if the authcode and user id exist in the database

}
?>

Link to comment
https://forums.phpfreaks.com/topic/274523-headers-aready-sent-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.