Warning message - What is wrong?

Discussion in 'PHP' started by CuBz, Jun 3, 2008.

  1. #1
    I am getting the following error:

    Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/content/a/m/a/amafiali/html/probe.php:1) in /home/content/a/m/a/amafiali/html/probe.php on line 2
    Code (markup):
    What is up with the following script:

    <?php
    session_start();
    include_once"includes/db_connect.php";
    include_once"includes/functions.php";
    logincheck();
    echo "<link href=includes/in.css rel=stylesheet type=text/css>";
    $username=$_SESSION['username'];
    $fetch=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'"));
    
    if ($fetch->last_script_check < time()){
    
    $eancol = rand(1,5);
    if($eancol == "1"){ $colour = "RED";
    }elseif($eancol == "2"){ $colour = "BLUE";
    }elseif($eancol == "3"){ $colour = "YELLOW";
    }elseif($eancol == "4"){ $colour = "GREEN";
    }elseif($eancol == "5"){ $colour = "ORANGE";
    }
    
    ?>
    
    
    <!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">
    <style type="text/css">
    <!--
    .style6 {color: #808080}
    -->
    </style>
    <head>
    <title>Untitled 1</title>
    <style type="text/css">
    .style3 {
    	text-align: center;
    	border: 1px solid #000000;
    	background-color: #808080;
    }
    .style4 {
    	text-align: center;
    	border: 1px solid #000000;
    	background-color: #666666;
    }
    .highlight {
    	text-align: center;
    	border: 1px solid #000000;
    	background-color: #CC0000;
    }
    .style5 {
    	font-size: 12px;
    	font-weight: bold;
    	color: $colour;
    }
    </style>
    </head>
    
    <body>
    <form method="post" action="">
      <table border="1" align="center" cellpadding="0" cellspacing="0" style="width: 50%">
    <tr>
    
    		<td height="21" colspan="4"  class=header class="style3"><center>Script Checker</td>
    	</tr>
    	<tr>
    		<td class="style4" colspan="4">Tick the radio box in <b><?php echo"<font color=$colour>$colour</font>";?></b></td>
    	</tr>
    	<tr>
    		<td align="center" bgcolor="<?php if($fetch->ver_code == "1"){ echo"$colour"; }else{ echo"#808080"; }?>" style="width: 25%; height: 38px"><input name="radio" type="radio" class="style6" value="1" /></td>
    
    		<td align="center" bgcolor="<?php if($fetch->ver_code == "2"){ echo"$colour"; }else{ echo"#808080"; }?>" style="width: 25%; height: 38px"><input name="radio" type="radio" value="2" /></td>
    		<td align="center" bgcolor="<?php if($fetch->ver_code == "3"){ echo"$colour"; }else{ echo"#808080"; }?>" style="width: 25%; height: 38px"><input name="radio" type="radio" value="3" /></td>
    		<td align="center" bgcolor="<?php if($fetch->ver_code == "4"){ echo"$colour"; }else{ echo"#808080"; }?>" style="width: 25%; height: 38px"><input name="radio" type="radio" value="4" /></td>
    	</tr>
    	<tr>
          <td align="center" bgcolor="<?php if($fetch->ver_code == "5"){ echo"$colour"; }else{ echo"#808080"; }?>"  style="width: 25%; height: 38px"><input name="radio" type="radio" value="5" /></td>
    	  <td align="center" bgcolor="<?php if($fetch->ver_code == "6"){ echo"$colour"; }else{ echo"#808080"; }?>"  style="width: 25%; height: 38px"><input name="radio" type="radio" value="6" /></td>
    	  <td align="center" bgcolor="<?php if($fetch->ver_code == "7"){ echo"$colour"; }else{ echo"#808080"; }?>"  style="width: 25%; height: 38px"><input name="radio" type="radio" value="7" /></td>
    	  <td align="center" bgcolor="<?php if($fetch->ver_code == "8"){ echo"$colour"; }else{ echo"#808080"; }?>" style="width: 25%; height: 38px"><input name="radio" type="radio" value="8" /></td>
        </tr>
    	<tr>
    		<td align="center" bgcolor="<?php if($fetch->ver_code == "9"){ echo"$colour"; }else{ echo"#808080"; }?>" style="width: 25%; height: 38px"><input name="radio" type="radio" value="9" /></td>
    		<td align="center" bgcolor="<?php if($fetch->ver_code == "10"){ echo"$colour"; }else{ echo"#808080"; }?>" style="width: 25%; height: 38px"><input name="radio" type="radio" value="10" /></td>
    		<td align="center" bgcolor="<?php if($fetch->ver_code == "11"){ echo"$colour"; }else{ echo"#808080"; }?>" style="width: 25%; height: 38px"><input name="radio" type="radio" value="11" /></td>
    		<td align="center" bgcolor="<?php if($fetch->ver_code == "12"){ echo"$colour"; }else{ echo"#808080"; }?>" style="width: 25%; height: 38px"><input name="radio"  type="radio" value="12" /></td>
    	</tr>
    	<tr>
    		<td height="35" colspan="4" class="style3"><input type="submit" name="submit" class="custombutton" value="Script Check">
    		  <br />
              <?php
    if($_POST['submit'] && $_POST['radio']){
    $radio=$_POST['radio'];
    if($radio != $fetch->ver_code){
    $randy = rand(1,12);
    if($randy == $radio){
    $newone = $radio + 1;}elseif($randy != $radio){ $newone = $randy;}
    if($newone > "12"){ $newone = "11"; }
    mysql_query("UPDATE users SET ver_code='$newone' WHERE username='$username'");
    echo"Wrong box!"; echo"<META http-equiv=\"refresh\" content=\"1;URL=probe.php\">";
    }else{
    $time=time()+(60*9);
    $randy = rand(1,12);
    if($randy == $radio){
    $newone = $radio + 1;}elseif($randy != $radio){ $newone = $randy;}
    if($newone > "12"){ $newone = "11"; } 
    mysql_query("UPDATE users SET last_script_check='$time', ver_code='$newone' WHERE username='$username'");
    echo "Correct code!";
    echo"<SCRIPT LANGUAGE='JavaScript'>
    history.go(-1)
    </script>";
    }
    }
    
    ?>          <br />        </td>
    	</tr>
    </table>
    </form>
    
    <?php
    exit();
    }
    
    ?>
    
    <?php 
    function script_check($file){
    }?>
    </body>
    
    </html>
    
    
    PHP:

    Also I am getting the following symbols in the top left corner of the page and i'm unsure why:

      
    Code (markup):

    Thanks
     
    CuBz, Jun 3, 2008 IP
  2. xlcho

    xlcho Guest

    Messages:
    532
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Most probably the editor you use to write the code is placing this special character. I've had some trouble with that. Try saving the file with another editor, or setting up your editor not to use any special characters.
     
    xlcho, Jun 3, 2008 IP
  3. CuBz

    CuBz Peon

    Messages:
    117
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I have used Editpad Lite for over a year and it hasnever happened
     
    CuBz, Jun 4, 2008 IP
  4. pubdomainshost.com

    pubdomainshost.com Peon

    Messages:
    1,277
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Remove all blank spaces before <? and after ?> from all files that are referenced in your code.
    Headers already sent comes typically due to blank spaces.

    Also verify each file for special character, even if editpad has not not given issues, it is possible that you may have copied something from the net and has saved the file with formatting info giving special character somewhere.
     
    pubdomainshost.com, Jun 4, 2008 IP
  5. SoftCloud

    SoftCloud Well-Known Member

    Messages:
    1,060
    Likes Received:
    28
    Best Answers:
    2
    Trophy Points:
    120
    #5
    Try adding:
    ob_start();
    Code (markup):
    Above the
    session_start();
    Code (markup):
     
    SoftCloud, Jun 4, 2008 IP
  6. Christian Little

    Christian Little Peon

    Messages:
    1,753
    Likes Received:
    80
    Best Answers:
    0
    Trophy Points:
    0
    #6
    
    include_once"includes/db_connect.php";
    include_once"includes/functions.php";
    logincheck();
    
    PHP:
    Do either of these files/functions declare session_start() in them? It's possible they are trying to initialize the session even though your main script does it before them.

    Also - you have a coding error. I doubt this will fix your error, but you are using include wrong, it should be:

    
    include_once("includes/db_connect.php");
    include_once("includes/functions.php");
    
    PHP:
     
    Christian Little, Jun 4, 2008 IP
  7. alvas

    alvas Peon

    Messages:
    17
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Try remove the symbol using hex editor, I've had that problem too when I using ultraedit, but now I'm using notepad++ and never get that problem anymore
     
    alvas, Jun 4, 2008 IP