Jump to content

how to remove warning: session_start?


mark103

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.