+ Reply to Thread
Results 1 to 5 of 5

Thread: session_start error...

  1. #1
    artfulme28 is offline x10Hosting Member artfulme28 is an unknown quantity at this point
    Join Date
    Jul 2011
    Posts
    10

    Question session_start error...

    With the servers' PHP update came new errors for my website. It started giving me this error:
    Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/artfulme/public_html/index.php:1) in /home/artfulme/public_html/index.php on line 1

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/artfulme/public_html/index.php:1) in /home/artfulme/public_html/index.php on line 1


    I need to fix this, but I have no clue how. Can someone help me? Here's my full page code:
    HTML Code:
    <?php session_start(); $_SESSION['loginreturn']="../index.php";  include("scripts/mysql.php"); ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <!-- Website Stuff -->
    <title>artfulME</title>
    <link rel="shortcut icon" href="images/favicon.ico" />
    
    <link href="css/index.css" rel="stylesheet" type="text/css" />
    <link href="css/login.css" rel="stylesheet" type="text/css" />
    </head>
    <body onload="MM_preloadImages('images/navi/homeover.png','images/navi/blogover.png','images/navi/mediaover.png','images/navi/blogover.PNG','images/navi/contactover.PNG')">
    <div id="wrapper">
      <p style="text-align: right; text-shadow: 1px 1px #000; height: 20px; margin-right: 3px">
      	<?php
    		if(!isset($_SESSION['loggedin'])){
    			echo "<a href='javascript:void(0);' id='showLogin' onclick=\"showElement('login');\">Login</a>\n";
    		}else{
    			if($_SESSION['username'] == "artfulME" || $_SESSION['username'] == "Admin"){
    				echo "<strong>Hello</strong> <a href='user/index.php'>".$_SESSION['username']."</a>!&nbsp;&nbsp; <a href='post/index.php'>Post</a> | <a href='userslist/index.php'>View Users List</a> | <a href='upload/index.php'>Upload</a> | <a onclick='document.logoutform.submit(); return false;' href='javascript:void(0);'>Logout</a><form style='display:none' id='logoutform' name='logoutform'  action='scripts/logout.php'></form>";
    				$_SESSION['accesstoadmin'] = 1;
    			}else{
    				echo "<strong>Hello</strong> <a href='user/index.php'>".$_SESSION['username']."</a>!&nbsp;&nbsp; <a onclick='document.logoutform.submit(); return false;' href='javascript:void(0);'>Logout</a><form style='display:none' id='logoutform' name='logoutform'  action='scripts/logout.php'></form>";
    			}
    		}
    	?></p>
      <div id="login">
        <span style="text-align: right"><p><img src="images/logintop.png" width="31" height="15" alt="logintop" /></p></span>
        <div id="cont1">
        <div style="height:5px"></div>
          <div id="cont2">
            <form id="loginform" name="loginform" method="post" action="scripts/login.php">
              <table width="100%" border="0" cellspacing="2" cellpadding="0">
                <tr>
                  <td><input name="entlogin" type="text" id="entlogin" onfocus="clearValue(this);" onblur="restoreValue(this);" value="Username or Email" maxlength="50" /></td>
                </tr>
                <tr>
                  <td><input name="entpass" type="text" id="entpass" onfocus="clearValue(this); changeTypeToPass(this);" onblur="restoreValue(this); changeTypeToText(this);" value="Password" maxlength="15" /></td>
                </tr>
                <tr>
                  <td><a href="javascript:void(0);" onclick="document.loginform.submit(); return false;">Continue</a> or <a href="signup/index.php">Signup!</a></td>
                </tr>
                <tr>
                  <td> <a href="javascript:void(0);"></a><a href="javascript:void(0);" onclick="hideElement('login');">Close</a></td>
                </tr>
              </table>
            </form>
          </div>
          <div style="height:5px"></div>
        </div>
      </div>
      <div id="header"><img src="images/logo.png" alt="artfulME" width="500" height="143" border="0" usemap="#Map" />
        <map name="Map" id="Map" title="Home | artfulME">
          <area shape="rect" coords="6,37,311,108" href="index.php" alt="Home | artfulME" />
        </map>
      </div>
      <div id="navi">
        <p><a href="index.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('HOME','','images/navi/homeover.png',1)"><img src="images/navi/home.png" alt="HOME" name="HOME" width="150" height="40" border="0" id="HOME" /></a><a href="blog/index.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('BLOG','','images/navi/blogover.PNG',1)"><img src="images/navi/blog.png" alt="BLOG" name="BLOG" width="145" height="40" border="0" id="BLOG" /></a><a href="media/index.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('MEDIA','','images/navi/mediaover.PNG',1)"><img src="images/navi/media.png" alt="MEDIA" name="MEDIA" width="156" height="40" border="0" id="MEDIA" /></a><a href="contact/index.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('CONTACT','','images/navi/contactover.PNG',1)"><img src="images/navi/contact.png" alt="CONTACT" name="CONTACT" width="205" height="40" border="0" id="CONTACT" /></a></p>
      </div>
      <div id="left">
        <div id="block1">
          <div id="container">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="50%"><h1>Video to be here soon!</h1></td>
              </tr>
              <tr>
                <td><p><a href="javascript:void(0);" id="showAbout" onclick="hideElement('showAbout'); showElement('moreAbout');">More about me...</a></p>
                  <p id="moreAbout" style="display:none"><a href="#" onclick="showElement('showAbout'); hideElement('moreAbout');">Hide more about me...</a><br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I'm not just your ordinary person. Most male humans my age play video games, watch Youtube, eat, and sleep. I do all of those things, but I bring them up a level. I make video games (sometimes), try my best at editing Youtube videos, and I eat a lot and sleep normally.<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Also, I'm a <em>very</em> good web-designer. This website is actually my best I'm sure... But, if you take a look at <a href="http://www.wildwestgraniteaz.com">www.wildwestgraniteaz.com</a> or <a href="http://villaingogh.x10.mx">villaingogh.x10.mx</a>, those are both my works.</p>
                  <p>&nbsp;</p></td>
              </tr>
            </table>
          </div>
        </div>
        <div id="block3">
          <div id="container">
            <h1>Recent tweets...</h1>
            <p>
              <script src="http://widgets.twimg.com/j/2/widget.js"></script>
              <script>
    new TWTR.Widget({
      version: 2,
      type: 'profile',
      rpp: 21,
      interval: 6000,
      width: 'auto',
      height: 300,
      theme: {
        shell: {
          background: '#282828',
          color: '#707071'
        },
        tweets: {
          background: '#282828',
          color: '#ffffff',
          links: '#708c37'
        }
      },
      features: {
        scrollbar: true,
        loop: false,
        live: false,
        hashtags: true,
        timestamp: true,
        avatars: false,
        behavior: 'all'
      }
    }).render().setUser('FethrdWlf').start();
      </script>
            </p>
          </div>
        </div>
      </div>
      <div id="right">
        <div id="block2">
          <div id="container">
          <?php
          	if(isset($_SESSION['flagged'])){
    			echo $_SESSION['flagged'];
    			unset($_SESSION['flagged']);
    		}elseif(isset($_SESSION['notflagged'])){
    			echo $_SESSION['notflagged'];
    			unset($_SESSION['notflagged']);
    		}
    	  ?>
            <h1>Most recent blog post...</h1>
            <?php include("scripts/latestpost.php"); ?>
    </div>
        </div>
        <div id="block4">
          <div id="container">
            <h1>My latest Youtube video:</h1>
            <p>
              <iframe style="margin-bottom: 5px;" width="434" height="277" src="http://www.youtube.com/embed/dUyAA_CT-S0" frameborder="0" allowfullscreen></iframe>
            </p>
          </div>
        </div>
      </div>
    </div>
    <div id="copyright" style="background-color:#7b7b7b">
        <p style="font-size: 12px">2011 &copy; artfulME, Johnny McNeil</p></div>
    </body>
    </html>

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: session_start error...

    Start with the likes of "Headers already sent" and "$_SESSION Problem state not changing" (a search for the error messages should have turned up at least the second one) and post an archived (e.g. zipped) copy of your script.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    John Rambo is offline x10Hosting Member John Rambo is an unknown quantity at this point
    Join Date
    Jun 2011
    Posts
    21

    Re: session_start error...

    It is listing of index.php, right? You have no spaces in the beginning of the file, usually it's the reason of this error. My guess, maybe your file is in UTF-8 encoding WITH SIGNATURE. There is extra character in the beginning of the file. Get rid of signature saving file without signature.

  4. #4
    tkdasearls32 is offline x10Hosting Member tkdasearls32 is an unknown quantity at this point
    Join Date
    Aug 2011
    Posts
    5

    Re: session_start error...

    did you get it to work? I am having the same issue.....

  5. #5
    callumacrae's Avatar
    callumacrae is offline not alex mac callumacrae is just really nice
    Join Date
    Dec 2007
    Location
    Wellesbourne, England
    Posts
    5,162

    Re: session_start error...

    Quote Originally Posted by tkdasearls32 View Post
    did you get it to work? I am having the same issue.....
    It's not the same fix for everyone. Post a new thread explaining your problem in detail, and give us some code to look at.
    I can customise your phpBB board. Send me a PM.
    lynxphp - info, tutorials and scripts
    "A forum post should be like a skirt; long enough to cover the subject but short enough to keep things interesting."

+ Reply to Thread

Similar Threads

  1. Replies: 4
    Last Post: 07-17-2009, 10:15 AM
  2. Problems with session_start()
    By anilson1 in forum Programming Help
    Replies: 3
    Last Post: 01-05-2009, 03:32 PM
  3. session_start() error - Not below any other ouput
    By andypalmer86 in forum Programming Help
    Replies: 7
    Last Post: 08-01-2008, 02:15 PM
  4. session_start() problems
    By chewett in forum Graphics & Webdesign
    Replies: 2
    Last Post: 11-24-2007, 11:15 AM
  5. session_start not working
    By namiiii in forum Free Hosting
    Replies: 4
    Last Post: 09-20-2007, 02:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers