Jump to content

Recommended Posts

Hey.

Im trying to have a page where when you login it brings you to that page and on the side theres information on your member stuff like username and name. Right now im able to do that but I get an error doing it. This is what im getting

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/xgame/public_html/random/index2.php:9) in /home/xgame/public_html/random/index2.php on line 146

You are logged in as supermerc

So it works, it tells me who im logged in as. Buts theres that error on top that I cant get ride of.

These are my lines 144-151

[code]<?php
ob_start();
session_start();
{
echo '<p>You are logged in as '.$_SESSION['s_username'].'</p>';
}
ob_end_flush();
?>[/code]

Also if you want to try it out to see what the problem is the site is http://xgame6overx.com/random/ You can use, supermerc as username and the pass is ilmilm.

Thank you.
Link to comment
https://forums.phpfreaks.com/topic/29611-needing-help-with-an-error/
Share on other sites

The error is just as it says...

more info here: http://www.phpfreaks.com/forums/index.php/topic,37442.0.html

You cant send headers... eg. cookies, header(), sessions... after displaying content (without output buffering EVERYTHING, it doesn't work in your example since it's halfway down the page)

You also don't need those curly brackets, like willfitch pointed out..

On a side note that template you have there is quite bold, I like it! Though it's too big for 800x600. And the text is too small for my resolution :D
Then where should i put it, i tried putting it on top but i got same error but on top instead.

This is my whole code

[code]<HTML>
<HEAD>
<LINK REL="SHORTCUT ICON" HREF="images/favicon.png>


<TITLE>random</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">

<style type="text/css">
<!--
.style3 {font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 10px; }
.style15 {font-size: 10px}
-->
</style>
</HEAD>
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 onLoad="MM_preloadImages('images/rimage_03.gif','images/rimage_05.gif','images/rimage_07.gif','images/rimage_09.gif','images/rimage_11.gif','images/rimage_13.gif','images/rimage_15.gif')">

<TABLE WIDTH=1000 BORDER=0 CELLPADDING=0 CELLSPACING=0>
<TR>
<TD COLSPAN=22>
<IMG SRC="images/image_01.gif" WIDTH=1000 HEIGHT=11 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=11 ALT=""></TD>
</TR>
<TR>
<TD ROWSPAN=2>
<IMG SRC="images/image_02.gif" WIDTH=186 HEIGHT=37 ALT=""></TD>
<TD COLSPAN=5><a href="home.php" target="main" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image85','','images/rimage_03.gif',1)"><img src="images/image_03.gif" name="Image85" width="62" height="30" border="0"></a></TD>
<TD ROWSPAN=2>
<IMG SRC="images/image_04.gif"  WIDTH=14 HEIGHT=37 ALT=""></TD>
<TD><a href="art.php" target="main" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image86','','images/rimage_05.gif',1)"><img src="images/image_05.gif" name="Image86" width="41" height="30" border="0"></a></TD>
<TD ROWSPAN=2>
<IMG SRC="images/image_06.gif" WIDTH=14 HEIGHT=37 ALT=""></TD>
<TD><a href="music.php" target="main" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image87','','images/rimage_07.gif',1)"><img src="images/image_07.gif" name="Image87" width="64" height="30" border="0"></a></TD>
<TD ROWSPAN=2>
<IMG SRC="images/image_08.gif" WIDTH=15 HEIGHT=37 ALT=""></TD>
<TD><a href="funny.php" target="main" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image88','','images/rimage_09.gif',1)"><img src="images/image_09.gif" name="Image88" width="132" height="30" border="0"></a></TD>
<TD ROWSPAN=2>
<IMG SRC="images/image_10.gif" WIDTH=14 HEIGHT=37 ALT=""></TD>
<TD><a href="forum.php" target="main" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image89','','images/rimage_11.gif',1)"><img src="images/image_11.gif" name="Image89" width="69" height="30" border="0"></a></TD>
<TD ROWSPAN=2>
<IMG SRC="images/image_12.gif" WIDTH=14 HEIGHT=37 ALT=""></TD>
<TD><a href="chat.php" target="main" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image90','','images/rimage_13.gif',1)"><img src="images/image_13.gif" name="Image90" width="52" height="30" border="0"></a></TD>
<TD ROWSPAN=2>
<IMG SRC="images/image_14.gif" WIDTH=14 HEIGHT=37 ALT=""></TD>
<TD COLSPAN=4><a href="love.php" target="main" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image91','','images/rimage_15.gif',1)"><img src="images/image_15.gif" name="Image91" width="118" height="30" border="0"></a></TD>
<TD ROWSPAN=2>
<IMG SRC="images/image_16.gif" WIDTH=191 HEIGHT=37 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=30 ALT=""></TD>
</TR>
<TR>
<TD COLSPAN=5>
<IMG SRC="images/image_17.gif" WIDTH=62 HEIGHT=7 ALT=""></TD>
<TD>
<IMG SRC="images/image_18.gif" WIDTH=41 HEIGHT=7 ALT=""></TD>
<TD>
<IMG SRC="images/image_19.gif" WIDTH=64 HEIGHT=7 ALT=""></TD>
<TD>
<IMG SRC="images/image_20.gif" WIDTH=132 HEIGHT=7 ALT=""></TD>
<TD>
<IMG SRC="images/image_21.gif" WIDTH=69 HEIGHT=7 ALT=""></TD>
<TD>
<IMG SRC="images/image_22.gif" WIDTH=52 HEIGHT=7 ALT=""></TD>
<TD COLSPAN=4>
<IMG SRC="images/image_23.gif" WIDTH=118 HEIGHT=7 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=7 ALT=""></TD>
</TR>
<TR>
<TD COLSPAN=22>
<IMG SRC="images/image_24.gif" WIDTH=1000 HEIGHT=17 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=17 ALT=""></TD>
</TR>
<TR>
<TD COLSPAN=22>
<a href="home.php" target="main"><IMG SRC="images/image_25.gif" ALT="" WIDTH=1000 HEIGHT=142 border="0"></a></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=142 ALT=""></TD>
</TR>
<TR>
<TD COLSPAN=22>
<IMG SRC="images/image_26.gif" WIDTH=1000 HEIGHT=17 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=17 ALT=""></TD>
</TR>
<TR>
<TD COLSPAN=3>
<IMG SRC="images/image_27.gif" WIDTH=220 HEIGHT=42 ALT=""></TD>
<TD ROWSPAN=12>
<IMG SRC="images/image_28.gif" WIDTH=6 HEIGHT=676 ALT=""></TD>
<TD COLSPAN=15 ROWSPAN=2>
<IMG SRC="images/image_29.gif" WIDTH=549 HEIGHT=52 ALT=""></TD>
<TD ROWSPAN=12>
<IMG SRC="images/image_30.gif" WIDTH=5 HEIGHT=676 ALT=""></TD>
<TD COLSPAN=2>
<IMG SRC="images/image_31.gif" WIDTH=220 HEIGHT=42 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=42 ALT=""></TD>
</TR>
<TR>
<TD COLSPAN=3 ROWSPAN=2>
<IMG SRC="images/image_32.gif" WIDTH=220 HEIGHT=15 ALT=""></TD>
<TD COLSPAN=2 ROWSPAN=2>
<IMG SRC="images/image_33.gif" WIDTH=220 HEIGHT=15 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=10 ALT=""></TD>
</TR>
<TR>
<TD COLSPAN=15 ROWSPAN=2 background=images/image_34.gif WIDTH=549 HEIGHT=113 ALT=></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=5 ALT=""></TD>
</TR>
<TR>
<TD COLSPAN=3 ROWSPAN=4 background=images/image_35.gif WIDTH=220 HEIGHT=200 ALT=><table border="0">
          <tr>
            <td width="220"><span class="style3">link</span></td>
          </tr>
          <tr>
            <td><span class="style3">link</span></td>
          </tr>
          <tr>
            <td><span class="style3">link</span></td>
          </tr>
          <tr>
            <td><span class="style3">link</span></td>
          </tr>
          <tr>
            <td><span class="style3">link</span></td>
          </tr>
          <tr>
            <td><span class="style3">link</span></td>
          </tr>
          <tr>
            <td><span class="style3">link</span></td>
          </tr>
          <tr>
            <td><span class="style3">link</span></td>
          </tr>
         
        </table></TD>
<TD COLSPAN=2 ROWSPAN=4 background=images/image_36.gif WIDTH=220 HEIGHT=200 ALT=>
<?php
ob_start();
session_start();
{
echo '<p>You are logged in as '.$_SESSION['s_username'].'</p>';
}
ob_end_flush();
?>
</TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=108 ALT=""></TD>
</TR>
<TR>
<TD COLSPAN=15>
<IMG SRC="images/image_37.gif" WIDTH=549 HEIGHT=22 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=22 ALT=""></TD>
</TR>
<TR>
<TD COLSPAN=15>
<IMG SRC="images/image_38.gif" WIDTH=549 HEIGHT=17 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=17 ALT=""></TD>
</TR>
<TR>
<TD ROWSPAN=5>
<IMG SRC="images/image_39.gif" WIDTH=14 HEIGHT=453 ALT=""></TD>
<TD COLSPAN=13 ROWSPAN=4 background=images/image_40.gif WIDTH=520 HEIGHT=439 ALT=><iframe src="home.php" name="main" width="520" height="439" frameborder="0"></iframe></TD>
<TD ROWSPAN=5>
<IMG SRC="images/image_41.gif" WIDTH=15 HEIGHT=453 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=53 ALT=""></TD>
</TR>
<TR>
<TD COLSPAN=2>
<IMG SRC="images/image_42.gif" WIDTH=218 HEIGHT=42 ALT=""></TD>
<TD ROWSPAN=5>
<IMG SRC="images/image_43.gif" WIDTH=2 HEIGHT=419 ALT=""></TD>
<TD COLSPAN=2 ROWSPAN=2>
<IMG SRC="images/image_44.gif" WIDTH=220 HEIGHT=57 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=42 ALT=""></TD>
</TR>
<TR>
<TD COLSPAN=2>
<IMG SRC="images/image_45.gif" WIDTH=218 HEIGHT=15 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=15 ALT=""></TD>
</TR>
<TR>
<TD COLSPAN=2 ROWSPAN=2 background=images/image_46.gif WIDTH=218 HEIGHT=343 ALT=>&nbsp;</TD>
<TD COLSPAN=2 ROWSPAN=2 background=images/image_47.gif WIDTH=220 HEIGHT=343 ALT=></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=329 ALT=""></TD>
</TR>
<TR>
<TD COLSPAN=13>
<IMG SRC="images/image_48.gif" WIDTH=520 HEIGHT=14 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=14 ALT=""></TD>
</TR>
<TR>
<TD COLSPAN=2>
<IMG SRC="images/image_49.gif" WIDTH=218 HEIGHT=19 ALT=""></TD>
<TD COLSPAN=15>
<IMG SRC="images/image_50.gif" WIDTH=549 HEIGHT=19 ALT=""></TD>
<TD COLSPAN=2>
<IMG SRC="images/image_51.gif" WIDTH=220 HEIGHT=19 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=19 ALT=""></TD>
</TR>
<TR>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=186 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=32 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=2 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=6 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=14 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=8 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=14 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=41 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=14 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=64 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=15 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=132 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=14 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=69 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=14 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=52 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=14 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=69 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=15 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=5 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=29 HEIGHT=1 ALT=""></TD>
<TD>
<IMG SRC="images/spacer.gif" WIDTH=191 HEIGHT=1 ALT=""></TD>
<TD></TD>
</TR>
</TABLE>
<!-- End ImageReady Slices -->
</BODY>
</HTML>[/code]

The only reason why i put it there is because i want the You are logged in as (username) in that table.
yeah, just leave the echo, and put the session_start(); at the VERY top of your script, not even a line break outside PHP tags before it. You don't even need to output buffer that tiny little section with the echo, all it is doing right now is slowing down the script a little.
You use <?php and ?> to jump in and out of PHP mode.  If you're inside of the <?php and ?> "tags," the text is interpreted as PHP and run as PHP.  If you're outside the tags it's seen as plain old text, whether or not it's HTML.

[code]
<?php
session_start();
?>
<html>
<head><title>hi2u</title></head>
<body>
<?
  // back inside php! YIPPEE!
  echo "my 'hi2u' page!<br />";
?>
</body>
</html>
[/code]
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.