lional Posted September 4, 2011 Share Posted September 4, 2011 Hi I am getting the following php error that is on all my pages and it works fine on the other pages except index.php <?php session_start(); include 'includes/conn_db.php'; if (isset($_POST['submit'])) { if (empty($_POST['userName'])) { $u = FALSE; $nouser = '<font color="red" size="2" face="arial">You forgot to enter your username!</font>'; } else { $u = $_POST['userName']; } if (empty($_POST['userPassword'])) { $p = FALSE; $nopass = '<font color="red" size="2" face="arial">You forgot to enter your password!</font>'; } else { $p = $_POST['userPassword']; } $errorMessage = $nouser . "<br>" . $nopass; if ($u && $p) { $query = "SELECT * from clients WHERE email = '$u' AND pword = '$p'"; $result = mysql_query($query, $conn); while ($row = mysql_fetch_assoc($result)){ if ($u == $row["email"] && $p == $row["pword"]) { $query_name = "SELECT * FROM clients WHERE email = '$u' AND pword = '$p'"; $result_name = @mysql_query ($query_name); while ($row_name = mysql_fetch_assoc($result_name)){ $client_id_out = $row_name['client_id']; $firstname_out = $row_name['firstname']; $lastname_out = $row_name['lastname']; // Create sessions $_SESSION['client_id'] = $client_id_out; $_SESSION['firstname'] = $firstname_out; $_SESSION['lastname'] = $lastname_out; ob_end_clean(); header ("Location: myaccount.php"); exit(); }} } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" /> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <link href="style.css" rel="stylesheet" type="text/css" /> <link href="layout.css" rel="stylesheet" type="text/css" /> <script src="js/jquery-1.3.2.min.js" type="text/javascript"></script> <script src="js/cufon-yui.js" type="text/javascript"></script> <script src="js/cufon-replace.js" type="text/javascript"></script> <script src="js/Futura_Bk_BT_400.font.js" type="text/javascript"></script> <script src="js/Futura_XBlk_BT_400.font.js" type="text/javascript"></script> <!--[if lt IE 7]> <script type="text/javascript" src="js/ie_png.js"></script> <script type="text/javascript"> ie_png.fix('.png'); </script> <![endif]--> </head> Thanks Lional Quote Link to comment https://forums.phpfreaks.com/topic/246393-headers-already-sent/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 4, 2011 Share Posted September 4, 2011 The error message, which you didn't post, states where the OUTPUT is occurring at that is causing the problem. The solution is to find and eliminate that output so that the header() statement will work. If you want us to directly help, you will need to post the error message. Quote Link to comment https://forums.phpfreaks.com/topic/246393-headers-already-sent/#findComment-1265289 Share on other sites More sharing options...
lional Posted September 4, 2011 Author Share Posted September 4, 2011 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/project/public_html/index.php:1) in /home/project/public_html/index.php on line 2 Quote Link to comment https://forums.phpfreaks.com/topic/246393-headers-already-sent/#findComment-1265290 Share on other sites More sharing options...
PFMaBiSmAd Posted September 4, 2011 Share Posted September 4, 2011 Thank you. For output started on line one of your main file, please read the last reply in this sticky post - http://www.phpfreaks.com/forums/index.php?topic=37442.0 You need to save the file without the BOM characters. Your programming editor will either have a choice in the 'file save as' menu or it will have a choice in a character encoding menu. Quote Link to comment https://forums.phpfreaks.com/topic/246393-headers-already-sent/#findComment-1265291 Share on other sites More sharing options...
lional Posted September 4, 2011 Author Share Posted September 4, 2011 Thank you for all your help Quote Link to comment https://forums.phpfreaks.com/topic/246393-headers-already-sent/#findComment-1265307 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.