supermerc Posted December 17, 2006 Share Posted December 17, 2006 This is the error im getting Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/xgame/public_html/random/edit_profile.php:1) in /home/xgame/public_html/random/edit_profile.php on line 2You must be logged in to edit your profile.And this is my code[code]<?php session_start(); ob_start(); require("config.php"); require("func.php"); //echo some styles to spice it up... echo " <style> body { background: #131313; font-family: Verdana, Arial; font-weight: bold; font-size: 9px; color: #FFFFFF; } .register_box { border: 1px solid #323232; background: #202020; font-family: Verdana, Arial; font-weight: bold; font-size: 9px; color: #FFFFFF; } </style> "; if(isset($_SESSION['logged_in'])) { $session_username = $_SESSION['username']; // further checking... if(username_exists($session_username)) { $get_info = mysql_query("SELECT email FROM users WHERE username = '$session_username' LIMIT 1"); if(mysql_num_rows($get_info) > 0) { $user_info = mysql_fetch_assoc($get_info); if(!isset($_POST['do_edit'])) { echo ' <form action="edit_profile.php" method="post"> <input type="text" name="email" value="' . $user_info['email'] . '" /> <br /> <input type="submit" name="do_edit" value="Edit Your Profile" /> </form> '; } elseif(isset($_POST['do_edit'])) { $email = mysql_real_escape_string($_POST['email']); // assign all errors to an array $errors = array(); if(empty($email)) { $errors[] = 'Your email was empty.'; } if(!is_valid_email($email)) { $errors[] = 'Your email was not in a valid email format.'; } // if array elements is greater than 0, // then we KNOW there was an error // else, no error, move on to processing if(count($errors) > 0) { echo '<b>ERRORS:</b><br />'; foreach($errors as $err) { echo $err . '<br />'; } } else { // everything is ok, update the DB mysql_query("UPDATE users SET email = '$email' WHERE username = '$session_username'"); echo 'Profile Edited.'; } } } else { echo 'Could not find profile info for your username.'; } } else { echo 'Sorry, your session username doesnt exist.'; } } else { echo 'You must be logged in to edit your profile.'; } ob_end_flush(); ?>[/code]I addedob_start(); at the beggening and ob_end_flush(); Because i read that it could solve the problem but it didnt. Quote Link to comment https://forums.phpfreaks.com/topic/30988-solved-help-session-problem-amp-header/ Share on other sites More sharing options...
kenrbnsn Posted December 17, 2006 Share Posted December 17, 2006 Do you have any HTML code preceding the "<?php"?Ken Quote Link to comment https://forums.phpfreaks.com/topic/30988-solved-help-session-problem-amp-header/#findComment-142996 Share on other sites More sharing options...
supermerc Posted December 17, 2006 Author Share Posted December 17, 2006 No thats my whole code Quote Link to comment https://forums.phpfreaks.com/topic/30988-solved-help-session-problem-amp-header/#findComment-142997 Share on other sites More sharing options...
ted_chou12 Posted December 17, 2006 Share Posted December 17, 2006 sorry to ask a stupid question, but what is the session_start() at the top for, do you really need it? try deleting it and entering the page. Quote Link to comment https://forums.phpfreaks.com/topic/30988-solved-help-session-problem-amp-header/#findComment-143010 Share on other sites More sharing options...
supermerc Posted December 17, 2006 Author Share Posted December 17, 2006 no you need that because its a page to edit your profile you need to be logged in for that Quote Link to comment https://forums.phpfreaks.com/topic/30988-solved-help-session-problem-amp-header/#findComment-143012 Share on other sites More sharing options...
ted_chou12 Posted December 17, 2006 Share Posted December 17, 2006 have you got other user pages (simple) ones that do work? or is this your user login page? if yes, try making another user page which is simple ie. just texts, no text area input fields forms and stuff. Quote Link to comment https://forums.phpfreaks.com/topic/30988-solved-help-session-problem-amp-header/#findComment-143019 Share on other sites More sharing options...
redbullmarky Posted December 17, 2006 Share Posted December 17, 2006 as ken said - check for code before the < ?php, even if you cant see anything. go DIRECTLY to the left of the very first < and press backspace a couple of times, save it, and try again.the sticky at the top of the php help forum (header/session errors) will explain several causes and solutions, but 9/10 in this case, it's due to something being output to the browser before your 'session_start'.cheers Quote Link to comment https://forums.phpfreaks.com/topic/30988-solved-help-session-problem-amp-header/#findComment-143026 Share on other sites More sharing options...
supermerc Posted December 17, 2006 Author Share Posted December 17, 2006 ya but like i said, theres NOTHING at all no space or anything before, thats it. Quote Link to comment https://forums.phpfreaks.com/topic/30988-solved-help-session-problem-amp-header/#findComment-143040 Share on other sites More sharing options...
kenrbnsn Posted December 17, 2006 Share Posted December 17, 2006 Sometimes there are unprintable characters there that have been known to cause problems. Try deleting that line and re-typing it.Ken Quote Link to comment https://forums.phpfreaks.com/topic/30988-solved-help-session-problem-amp-header/#findComment-143042 Share on other sites More sharing options...
moshdj2uk Posted December 17, 2006 Share Posted December 17, 2006 Are you including this file from another file? Quote Link to comment https://forums.phpfreaks.com/topic/30988-solved-help-session-problem-amp-header/#findComment-143043 Share on other sites More sharing options...
supermerc Posted December 17, 2006 Author Share Posted December 17, 2006 There was 1 space actually that i missed, now the error is gone but i still have an error saying that im not logged in.Please check it out yourself.http://xgame6overx.com/randomJust use supermerc as username and ilmilm as password unless you want to register.Click My profile to see what im trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/30988-solved-help-session-problem-amp-header/#findComment-143045 Share on other sites More sharing options...
supermerc Posted December 17, 2006 Author Share Posted December 17, 2006 I managed to fix it Quote Link to comment https://forums.phpfreaks.com/topic/30988-solved-help-session-problem-amp-header/#findComment-143111 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.