IPB

Welcome Guest ( Log In | Register )



Tags
This content has not been tagged yet
 
Reply to this topicStart new topic

Session_start()

, whats going on with it


illdevilinc
no avatar
Premium Member
********
Group: Members
Posts: 157
Joined: 28-January 06
From: San leandro, California, USA
Member No.: 17,828



Post #1 post Mar 9 2006, 08:00 PM
Hi im using my page in php coding and the session_start() code is messing something up.
This is the error:
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/idimm/public_html/index.html:2) in /home/idimm/public_html/index.html on line 103

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/idimm/public_html/index.html:2) in /home/idimm/public_html/index.html on line 103:
Does anyone know how to fix this? It does do the command but it gives this annoying error message no madder what. Please help i would like to get this feature working on my site. This is being a very hard code. Stupid PHP. But heres the url for the site if you want to go to it and see the error your self. The error page.
thanks,
me
Go to the top of the page
+Quote Post
Hat
no avatar
Newbie [Level 1]
*
Group: Members
Posts: 20
Joined: 28-January 06
Member No.: 17,811



Post #2 post Mar 9 2006, 09:14 PM
index.html has to be changed to .php for one thing...and thats I'm all I'm good for, because I suck at PHP.
Go to the top of the page
+Quote Post
jlhaslip
no avatar
<?php $answer = googleit( $question ) ; ?>
*******************
Group: [MODERATOR]
Posts: 4,433
Joined: 24-July 05
From: Linix, DOS and Windows…the good, the bad and the ugly
Member No.: 9,787
Spam Patrol
myCENT:74.90



Post #3 post Mar 9 2006, 09:57 PM
Well there is a problem right at the top of your page which needs to be sorted out before you get any further along. There are some things way out of place and missing.
The typical sequence for an html (or htm) page should be something like this:
CODE

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<link rel="shortcut icon" href="favicon.ico" />
<link href="something.css" rel="stylesheet" type="text/css" media="all">
  <title>Demo title</title>
  <style type="text/css" media="screen">
<!-- Insert the embedded styles here -->
  </style>
<script type="text/javascript">
onload = function() { content.focus() }
</script>
</head>
   <body>

<!-- Main Html Code for the page -->

</body>
</html>


I did a view source of the trap17 page to snag some of this, so it might not be exactly what you want, but the order of the tags is what I was attempting to show you. The Doc Types must be exactly coded or they will blow up pretty quickly.
Now do a view > source of your page and compare the two.
You don't have a Doc Type, the first tag is a style tag, there are several other things there to fix up before you get to the Header problem.

After you have fixed these things as best as you can, run the page through the w3c Validator at their site, www.w3c.org, to make sure it passes. The validation won't check logic or php errors, but it will tell you if all is well with the syntax of the page.

As for the Headers, see the php manual at http://ca.php.net/manual/en/function.header.php. There are also rules about how to send the Cookies used for the sessions.
QUOTE

setcookie() defines a cookie to be sent along with the rest of the HTTP headers. Like other headers, cookies must be sent before any output from your script (this is a protocol restriction). This requires that you place calls to this function prior to any output, including <html> and <head> tags as well as any whitespace. If output exists prior to calling this function, setcookie() will fail and return FALSE. If setcookie() successfully runs, it will return TRUE. This does not indicate whether the user accepted the cookie.
Go to the top of the page
+Quote Post
illdevilinc
no avatar
Premium Member
********
Group: Members
Posts: 157
Joined: 28-January 06
From: San leandro, California, USA
Member No.: 17,828



Post #4 post Mar 9 2006, 10:10 PM
QUOTE(Hat @ Mar 9 2006, 01:14 PM) [snapback]234911[/snapback]

index.html has to be changed to .php for one thing...and thats I'm all I'm good for, because I suck at PHP.

I am using a .htaccess file so i dont need to change the type of page.

QUOTE(jlhaslip @ Mar 9 2006, 01:57 PM) [snapback]234920[/snapback]

Well there is a problem right at the top of your page which needs to be sorted out before you get any further along. There are some things way out of place and missing.
The typical sequence for an html (or htm) page should be something like this:
CODE

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<link rel="shortcut icon" href="favicon.ico" />
<link href="something.css" rel="stylesheet" type="text/css" media="all">
  <title>Demo title</title>
  <style type="text/css" media="screen">
<!-- Insert the embedded styles here -->
  </style>
<script type="text/javascript">
onload = function() { content.focus() }
</script>
</head>
   <body>

<!-- Main Html Code for the page -->

</body>
</html>


I did a view source of the trap17 page to snag some of this, so it might not be exactly what you want, but the order of the tags is what I was attempting to show you. The Doc Types must be exactly coded or they will blow up pretty quickly.
Now do a view > source of your page and compare the two.
You don't have a Doc Type, the first tag is a style tag, there are several other things there to fix up before you get to the Header problem.

After you have fixed these things as best as you can, run the page through the w3c Validator at their site, www.w3c.org, to make sure it passes. The validation won't check logic or php errors, but it will tell you if all is well with the syntax of the page.

As for the Headers, see the php manual at http://ca.php.net/manual/en/function.header.php. There are also rules about how to send the Headers.

The page was generated by Microsoft Frontpage 2003. The headers were automaticly generated by frontpage and the code has been checked by it. Im not sure if this is the problem because the problem is that i am putting the php code in a TABLE and it requires a seesion_start() which i have just found out that it must be on the top of the page to function properly. If i put the whole code up on the top it works fine but if it is in the table i get a error. I have no idea how to get it to work in the tables but i am experimenting with it and everything so far has failed. If anyone has any information on how to put this kind of code in a table please help me.
here is the code
CODE
<?php
session_start();
//check to see if the user already has an open session
if (($_SESSION[user_name] != "") && ($_SESSION[password] != ""))
{
    echo"Favorites--Logout";
}
else
    echo"Login";
?>

and here is the code for the shared border that this code is in
CODE
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Shared Top Border</title>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta name="Microsoft Theme" content="none">
<meta name="Microsoft Border" content="none">
</head>

<body>

<p align="left"><font color="#808080" size="2"><br>
</font><font color="#FFFF00">We Now support
<script type="text/javascript"><!--
google_ad_client = "pub-7806936936690646";
google_ad_width = 180;
google_ad_height = 60;
google_ad_format = "180x60_as_rimg";
google_cpa_choice = "CAAQ24Oy0QEaCGbgW7AaXRokKMu293M";
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br>
</font><font size="2">
<!--webbot bot="Navigation" s-type="top" s-orientation="horizontal" s-rendering="graphics" b-include-home="TRUE" b-include-up="TRUE" s-theme="classic 0010" --></font></p>
<div style="position: absolute; width: 100px; height: 100px; z-index: 16; left: 740px; top: 16px" id="layer21">
    <p align="center"><!--webbot bot="HTMLMarkup" startspan --><form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="illdevilinc@gmail.com">
<input type="image" src="https://www.paypal.com/en_US/i/btn/view_cart.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<input type="hidden" name="display" value="1">
</form><!--webbot bot="HTMLMarkup" endspan --></div>
<p align="center"><font size="2">
<img border="0" src="../images/IDI%20METAL%20MUSIC%20LOGO.JPG" width="84" height="65" alt="Metal Music" align="left"></font></p>
<div style="position: absolute; width: 505px; height: 62px; z-index: 10; left: 181px; top: 233px" id="layer14">
    <p align="center">Advertisement<font size="1">▼</font>
    <script type="text/javascript"><!--
google_ad_client = "pub-7806936936690646";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "333333";
google_color_bg = "000000";
google_color_link = "FFFFFF";
google_color_url = "999999";
google_color_text = "CCCCCC";
//--></script>
    <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<table border="1" width="100%" id="table2">
    <tr>
        <td><?php
session_start();
//check to see if the user already has an open session
if (($_SESSION[user_name] != "") && ($_SESSION[password] != ""))
{
    echo"Favorites--Logout";
}
else
    echo"Login";
?></td>
        <td> </td>
        <td> </td>
    </tr>
</table>
<div style="position: absolute; width: 510px; height: 100px; z-index: 17; left: 181px; top: 327px" id="layer22">
    <p align="center">Need to find something?  Then search our site! 
    (Provided by Google)<br>
    <!--webbot bot="HTMLMarkup" startspan --><!-- SiteSearch Google --> </p>
<form method="get" action="http://www.google.com/custom" target="google_window">
    <table border="0" bgcolor="#000000">
        <tr>
            <td nowrap="nowrap" valign="top" align="left" height="32">
            <p align="right"></td>
            <td nowrap="nowrap" align="center">
            <input type="hidden" name="domains" value="metalmusic.trap17.com">
            <p align="right">
            <input type="text" name="q" size="10" maxlength="255" value>
            <input type="submit" name="sa" value="Google Search"> </td>
        </tr>
        <tr>
            <td>
            <p align="right"> </td>
            <td nowrap="nowrap" align="center">
            <table>
                <tr>
                    <td>
                    <p align="right">
                    <input type="radio" name="sitesearch" value checked="checked">
                    <font size="-1" color="#ffffff">Web</font> </td>
                    <td>
                    <p align="right">
                    <input type="radio" name="sitesearch" value="metalmusic.trap17.com">
                    <font size="-1" color="#ffffff">metalmusic.trap17.com</font>
                    </td>
                </tr>
            </table>
            <input type="hidden" name="client" value="pub-#############">
            <p align="right"><input type="hidden" name="forid" value="1">
            <input type="hidden" name="ie" value="##########">
            <input type="hidden" name="oe" value="################">
            <input type="hidden" name="safe" value="active">
            <input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;FORID:1;">
            <input type="hidden" name="hl" value="en"></td>
        </tr>
    </table>
</form>
<p>
<!-- SiteSearch Google --></p>
<!--webbot bot="HTMLMarkup" endspan --></div>
<p align="center"> </p>

</body>

</html>

thank you for the people that are willing to help me

This post has been edited by illdevilinc: Mar 9 2006, 10:16 PM
Go to the top of the page
+Quote Post
jlhaslip
no avatar
<?php $answer = googleit( $question ) ; ?>
*******************
Group: [MODERATOR]
Posts: 4,433
Joined: 24-July 05
From: Linix, DOS and Windows…the good, the bad and the ugly
Member No.: 9,787
Spam Patrol
myCENT:74.90



Post #5 post Mar 9 2006, 10:54 PM
Quoted from the php manual $session_start():
QUOTE

NOTE: If you are using cookie-based sessions, you must call session_start() before anything is output to the browser.

Sorry, I mistakenly referenced to the $set_cookies (). So, yes, having the #session_start() in the middle of the tablet, after output has started to the browser will throw an error.
Go to the top of the page
+Quote Post
OpaQue
no avatar
Administrator
**************
Group: Admin
Posts: 1,583
Joined: 11-June 04
From: Somewhere in Time & Space.
Member No.: 1
myCENT:21.29



Post #6 post Mar 9 2006, 11:34 PM
Check all your INCLUDE / REQUIRE files and see if there is any space left

CODE
after

?>


OR

CODE
Before

<?

Go to the top of the page
+Quote Post
illdevilinc
no avatar
Premium Member
********
Group: Members
Posts: 157
Joined: 28-January 06
From: San leandro, California, USA
Member No.: 17,828



Post #7 post Mar 10 2006, 01:19 AM
I have tried callin session_start() before the html coding but i cant have my loogin/logout coding at the top. I am trying to keep them in the table that i have created for them but im not sure how to do it. I have tried caling session start like this:
<?
Session_start()
?>
HTML CODE
<?
LOGIN SCRIPT CODE
?>
But it did not give an error but didnt work. If anyone knows something i could do to call the session before the html but still have the actual login/logout script in the table please tell it to me.
Im sorry i wasnt clear of my problem.
And thanks for trying to help me!
Go to the top of the page
+Quote Post
jlhaslip
no avatar
<?php $answer = googleit( $question ) ; ?>
*******************
Group: [MODERATOR]
Posts: 4,433
Joined: 24-July 05
From: Linix, DOS and Windows…the good, the bad and the ugly
Member No.: 9,787
Spam Patrol
myCENT:74.90



Post #8 post Mar 10 2006, 02:22 AM
Post the code for the entire page including the Login Script, please. Doing a view source doesn't show the php script or form handling. Might be something there.
Go to the top of the page
+Quote Post
moldboy
no avatar
Privileged Member
*********
Group: Members
Posts: 516
Joined: 29-April 05
From: Canada Eh?!?
Member No.: 6,408



Post #9 post Mar 10 2006, 03:19 AM
You say you want the login in the table with the form. That makes sense, it's the natural way to program, and when I first started php the lack of a goto function drove me crazy. The reason the model you have tried (but can't get to wirk) isn't returning an error is because you set the page up properly. Session_start() must be the first line sent to the browser, so fir example in the following code (I just wrote this there may be errors)
CODE

<html>
<head>
</head>
<body>
<?php
if $sessions == TRUE{
session_start();
};
else {
echo "<p>session were not requested</p>";
};
?>
</body>
</html>

this code will result in an if session == TRUE because it will try to start the session after the browser has recieved code (the <html>... stuff)

Umm, you really need to post a little more code, If you use session_start() at the top of the page so it doesn't return an error, then you should be able to set session variables at any point later in the page. It may very well be the way you are calling the variables that results in it not working.

That's all I can think of right now, without more code, I'm sorry I can't be of more help
Go to the top of the page
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No New Posts   1 TheMoose 112 10th December 2008 - 02:45 AM
Last post by: Kedishen


 



RSS Open Discussion Time is now: 8th January 2009 - 09:37 AM