mark103 Posted April 9, 2013 Share Posted April 9, 2013 Hi guys,I need your help. I got a problem with my php script where i cannot ignore the warning: session_start. The warning I get is: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/myusername/public_html/test.php:6) in /home/myusername/public_html/test.php on line 7 <html> <body> <table> <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'myusername'); define('DB_PASSWORD', 'mypassword'); define('DB_DATABASE', 'mydbname'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; echo implode('<br />',$errmsg_arr); } else { $qrytable1="SELECT id, channels FROM tvguide"; $result1=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error()); while ($row = mysql_fetch_array($result1)) { echo "<tr><td>".$row['channels']."</td></tr>"; } } ?> </table> </html> Does anyone know what the trouble is and how to remove the warning session_start?thanks in advance Quote Link to comment Share on other sites More sharing options...
requinix Posted April 9, 2013 Share Posted April 9, 2013 Asking how to remove the warning is the wrong question. You should be asking how to fix the problem that's causing the warning. Which, in this case, is the same thing because session_start() simply is not working for you. You can't use it if you've outputted anything. Rearrange your code so that you call session_start() as close to the beginning of the script as possible. Quote Link to comment Share on other sites More sharing options...
Yohanne Posted April 10, 2013 Share Posted April 10, 2013 try it. if the user is already in , in secute page you do not need to call this $errflag instead of calling the database parater to show up what you need to show. Quote Link to comment 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.