Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting a really annoying error when I want to start a session in php
    text
    copied!<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/3801178/php-headers-already-sent">PHP headers already sent</a><br> <a href="https://stackoverflow.com/questions/6005702/php-session-start-error">PHP session_start() error?</a> </p> </blockquote> <p>I'm getting this error:</p> <blockquote> <p>Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\index.php:27) in C:\xampp\htdocs\connect.php on line 2</p> <p>Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\index.php:27) in C:\xampp\htdocs\connect.php on line 2</p> </blockquote> <p>I'm don't have a clue what this means or how to handle it!! ANY help will be very appreciated!</p> <p>Here is my 2 files that "causes" the problem:</p> <p><strong>connect.php</strong></p> <pre><code>&lt;?php session_start(); $server = 'localhost'; $username = 'root'; $password = ''; $database = 'mydatabase'; if(!mysql_connect('localhost', 'root', '')) { exit('Error: could not establish database connection'); } if(!mysql_select_db($database)) { exit('Error: could not select the database'); } ?&gt; </code></pre> <p><strong>index.php</strong></p> <pre><code>&lt;!DOCTYPE HTML&gt; &lt;head&gt; &lt;title&gt; ShareLink &lt;/title&gt; &lt;link rel="stylesheet" href="style.css" type="text/css"&gt; &lt;link rel="stylesheet" type="text/css" media="screen,projection" href="css/ui.totop.css" /&gt; &lt;script src="js/jquery-1.3.2.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="js/easing.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="js/jquery.ui.totop.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { var defaults = { containerID: 'moccaUItoTop', // fading element id containerHoverClass: 'moccaUIhover', // fading element hover class scrollSpeed: 1200, easingType: 'linear' }; $().UItoTop({ easingType: 'easeOutQuart' }); }); &lt;/script&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;?php include 'connect.php'; include 'header.php'; $sql = "SELECT categories.cat_id, categories.cat_name, categories.cat_description, COUNT(topics.topic_id) AS topics FROM categories LEFT JOIN topics ON topics.topic_id = categories.cat_id GROUP BY categories.cat_name, categories.cat_description, categories.cat_id"; $result = mysql_query($sql); if(!$result) { echo 'The categories could not be displayed, please try again later.'; } else { if(mysql_num_rows($result) == 0) { echo '&lt;br/&gt;'; echo '&lt;h3&gt;Welcome to ShareLink! Here you can rate and share links with other users.&lt;/h3&gt;'; echo '&lt;br/&gt;'; echo 'Please &lt;a href="signup.php"&gt;&lt;b&gt;register&lt;/b&gt;&lt;/a&gt; or &lt;a href="signin.php"&gt;&lt;b&gt;log in&lt;/b&gt;&lt;/a&gt; to start sharing your links...'; echo '&lt;br/&gt;&lt;br/&gt;'; } else { //prepare the table echo '&lt;table border="1"&gt; &lt;tr&gt; &lt;th&gt;Category&lt;/th&gt; &lt;th&gt;Last topic&lt;/th&gt; &lt;/tr&gt;'; while($row = mysql_fetch_assoc($result)) { echo '&lt;tr&gt;'; echo '&lt;td class="leftpart"&gt;'; echo '&lt;h3&gt;&lt;a href="category.php?id=' . $row['cat_id'] . '"&gt;' . $row['cat_name'] . '&lt;/a&gt;&lt;/h3&gt;' . $row['cat_description']; echo '&lt;/td&gt;'; echo '&lt;td class="rightpart"&gt;'; //fetch last topic for each cat $topicsql = "SELECT topic_id, topic_subject, topic_date, topic_cat FROM topics WHERE topic_cat = " . $row['cat_id'] . " ORDER BY topic_date DESC LIMIT 1"; $topicsresult = mysql_query($topicsql); if(!$topicsresult) { echo 'Last topic could not be displayed.'; } else { if(mysql_num_rows($topicsresult) == 0) { echo 'no topics'; } else { while($topicrow = mysql_fetch_assoc($topicsresult)) echo '&lt;a href="topic.php?id=' . $topicrow['topic_id'] . '"&gt;' . $topicrow['topic_subject'] . '&lt;/a&gt; at ' . date('d-m-Y', strtotime($topicrow['topic_date'])); } } echo '&lt;/td&gt;'; echo '&lt;/tr&gt;'; } } //rate the link //echo '&lt;tr&gt;&lt;td&gt;&lt;b&gt;Rate this link&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;'; } //include 'footer.php'; ?&gt; </code></pre> <p>Like I said, I really need to get this working so your help will mean a lot!</p>
 

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