andrew_biggart Posted February 15, 2013 Share Posted February 15, 2013 (edited) 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 } ?> Edited February 15, 2013 by andrew_biggart Quote Link to comment https://forums.phpfreaks.com/topic/274523-headers-aready-sent-error/ Share on other sites More sharing options...
trq Posted February 15, 2013 Share Posted February 15, 2013 The error tells you exactly where the problem is. What is the exact error? Even from your simple post I'm pretty sure I can see a blank line before your <?php tag. Quote Link to comment https://forums.phpfreaks.com/topic/274523-headers-aready-sent-error/#findComment-1412596 Share on other sites More sharing options...
andrew_biggart Posted February 15, 2013 Author Share Posted February 15, 2013 It's fine, it was just me being stupid. I've moved the script to the very top of the page and used variables to output any errors. Thanks Andrew Quote Link to comment https://forums.phpfreaks.com/topic/274523-headers-aready-sent-error/#findComment-1412600 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.