garydt Posted June 17, 2007 Share Posted June 17, 2007 I can't see what I'm outputting to the screen before the headers as i'm gettinng 'cannot modify header' error. <?php require_once('Connections/elvisdb.php'); ?> <?php session_start(); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $user = ($_SESSION['MM_Username']); mysql_select_db($database_elvisdb, $elvisdb); $query_Recordset3 = "SELECT * FROM userinformation ORDER BY id DESC"; $Recordset3 = mysql_query($query_Recordset3, $elvisdb) or die(mysql_error()); $row_Recordset3 = mysql_fetch_assoc($Recordset3); $totalRows_Recordset3 = mysql_num_rows($Recordset3); $field = $row_Recordset3['id']; $pass = $row_Recordset3['password']; $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE userinformation SET usernm=%s WHERE id='$field'", GetSQLValueString($_POST['textfield'], "text")); mysql_select_db($database_elvisdb, $elvisdb); $Result1 = mysql_query($updateSQL, $elvisdb) or die(mysql_error()); // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['textfield'])) { $loginUsername=$_POST['textfield']; $password=$_POST['hiddenField']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "logdonuserpagenew.php"; $MM_redirectLoginFailed = "logdonuserpagenew.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_elvisdb, $elvisdb); $LoginRS__query=sprintf("SELECT usernm, password FROM userinformation WHERE usernm=%s AND password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $elvisdb) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; header("Location: logdonuserpagenew.php"); } } } Quote Link to comment https://forums.phpfreaks.com/topic/55962-another-header-problem/ Share on other sites More sharing options...
Lumio Posted June 17, 2007 Share Posted June 17, 2007 If one error raised you can't set the header anymore. To use header() you can't output anything. so: <?php header('foo:bar'); // you new header echo 'something'; // output something. ?> Quote Link to comment https://forums.phpfreaks.com/topic/55962-another-header-problem/#findComment-276404 Share on other sites More sharing options...
garydt Posted June 17, 2007 Author Share Posted June 17, 2007 Thanks. I've got a header location command at line 87, im not outputting anything to the screen before that so i can't see why i'm getting modifying header error. Quote Link to comment https://forums.phpfreaks.com/topic/55962-another-header-problem/#findComment-276440 Share on other sites More sharing options...
Lumio Posted June 17, 2007 Share Posted June 17, 2007 what is in line 87? Quote Link to comment https://forums.phpfreaks.com/topic/55962-another-header-problem/#findComment-276441 Share on other sites More sharing options...
GingerRobot Posted June 17, 2007 Share Posted June 17, 2007 You say you're not outputting anything to the screen, but two things: firstly, did you check through your included files to make sure they dont ouput anything. Second, dont forget about whitespace. The blank line at the top of the code you posted looks to me like it could be some whitespace - perhaps a newline character. You'll need to remove that too. Quote Link to comment https://forums.phpfreaks.com/topic/55962-another-header-problem/#findComment-276444 Share on other sites More sharing options...
teng84 Posted June 18, 2007 Share Posted June 18, 2007 tips bro: i think the error is that the declaration of session that should always be at the top of every page see this thing : <?php require_once('Connections/elvisdb.php'); ?> <?php session_start(); ?> thats what your trying to do i suggest try doing like this <?php session_start(); require_once('Connections/elvisdb.php'); ?> if theres is no printing action on any part cause i dont want to read your whole codes that should work note: no space on the top <?php Quote Link to comment https://forums.phpfreaks.com/topic/55962-another-header-problem/#findComment-276502 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.