Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP - Headers Already Sent Caused By session_start();?
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/8028957/headers-already-sent-by-php">Headers already sent by PHP</a> </p> </blockquote> <p>EDIT** I have now fixed the headers already sent up to the point where, line 53 ie. Last line in my common.php, which starts the session, is causing headers already sent. So now where am I supposed to put my session_start?</p> <p>My index.php -</p> <pre><code>&lt;?php require("common.php"); if(empty($_SESSION['user'])) { header("Location: login.php"); die("Redirecting to login.php"); } ?&gt; &lt;!DOCTYPE html&gt; &lt;!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ --&gt; &lt;!--[if lt IE 7]&gt; &lt;html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"&gt; &lt;![endif]--&gt; &lt;!--[if IE 7]&gt; &lt;html class="no-js lt-ie9 lt-ie8" lang="en"&gt; &lt;![endif]--&gt; &lt;!--[if IE 8]&gt; &lt;html class="no-js lt-ie9" lang="en"&gt; &lt;![endif]--&gt; &lt;!--[if gt IE 8]&gt;&lt;!--&gt; &lt;html class="no-js" lang="en"&gt; &lt;!--&lt;![endif]--&gt; &lt;head&gt; &lt;meta charset="utf-8" /&gt; &lt;!-- Set the viewport width to device width for mobile --&gt; &lt;meta name="viewport" content="width=device-width" /&gt; &lt;title&gt;nCMS | Simplicity, Reimagined.&lt;/title&gt; &lt;!-- Included CSS Files (Uncompressed) --&gt; &lt;!-- &lt;link rel="stylesheet" href="stylesheets/foundation.css"&gt; --&gt; &lt;!-- Included CSS Files (Compressed) --&gt; &lt;link rel="stylesheet" href="stylesheets/foundation.min.css"&gt; &lt;link rel="stylesheet" href="stylesheets/app.css"&gt; &lt;script src="javascripts/modernizr.foundation.js"&gt;&lt;/script&gt; &lt;!-- IE Fix for HTML5 Tags --&gt; &lt;!--[if lt IE 9]&gt; &lt;script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"&gt;&lt;/script&gt; &lt;![endif]--&gt; &lt;/head&gt; &lt;body&gt; &lt;!--INCLUDE HEADER --&gt; &lt;?PHP include('header.php'); ?&gt; &lt;!--/INCLUDE HEADER --&gt; &lt;!--INCLUDE PAGE --&gt; &lt;div class="row"&gt; Hello &lt;?php echo htmlentities($_SESSION['user']['username'], ENT_QUOTES, 'UTF-8'); ?&gt;, secret content!&lt;br /&gt; &lt;h3&gt;Hi, I'm Index!&lt;/h3&gt; &lt;/div&gt; &lt;!--/INCLUDE PAGE--&gt; &lt;!--INCLUDE FOOTER--&gt; &lt;?PHP include('footer.php'); ?&gt; &lt;!--/INCLUDE FOOTER--&gt; &lt;!-- Included JS Files (Compressed) --&gt; &lt;script src="javascripts/jquery.js"&gt;&lt;/script&gt; &lt;script src="javascripts/foundation.min.js"&gt;&lt;/script&gt; &lt;!-- Initialize JS Plugins --&gt; &lt;script src="javascripts/app.js"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This is the live page - <a href="http://www.cogameservers.com/ncms" rel="nofollow noreferrer">http://www.cogameservers.com/ncms</a></p> <p>Thank you for any help - Necro</p> <hr> <p>common.php - </p> <pre><code>&lt;?php $username = ""; $password = ""; $host = ""; $dbname = ""; $options = array(PDO::MYSQL_ATTR_INIT_COMMAND =&gt; 'SET NAMES utf8'); try { $db = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $username, $password, $options); } catch(PDOException $ex) { die("Failed to connect to the database: " . $ex-&gt;getMessage()); } $db-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db-&gt;setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); if(function_exists('get_magic_quotes_gpc') &amp;&amp; get_magic_quotes_gpc()) { function undo_magic_quotes_gpc(&amp;$array) { foreach($array as &amp;$value) { if(is_array($value)) { undo_magic_quotes_gpc($value); } else { $value = stripslashes($value); } } } undo_magic_quotes_gpc($_POST); undo_magic_quotes_gpc($_GET); undo_magic_quotes_gpc($_COOKIE); } header('Content-Type: text/html; charset=utf-8'); session_start(); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload