Re: Re[2]: [PHP] sessions help

2002-06-13 Thread Miguel Cruz

On Thu, 13 Jun 2002, Kevin Stone wrote:
> Your problem is here..
> >  return ($_SESSION['node'] = $node_id);
> 
> I do not believe that you can both set and return a varaible on the same
> line.  FYI, the variable which you're returning in this function is global..
> so there's no reason to return it anyway.  Just fill the index and you're
> all set.

There's no particular reason that in itself shouldn't work - the return 
value of an assignment is the result of the assignment.

Try:

   $i = 1;
   echo $i = $i + 3;

miguel


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: Re[2]: [PHP] sessions help

2002-06-13 Thread Kevin Stone

Your problem is here..
>  return ($_SESSION['node'] = $node_id);

I do not believe that you can both set and return a varaible on the same
line.  FYI, the variable which you're returning in this function is global..
so there's no reason to return it anyway.  Just fill the index and you're
all set.
-Kevin


- Original Message -
From: "Leston Drake" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, June 13, 2002 3:32 PM
Subject: Re[2]: [PHP] sessions help


> Thanks to Julie and Stuart for helping me.
>
> With your direction, I got rid of the warning about the headers by putting
> the session_start() at the beginning of the file.
>
> Now I get a different sort of error when I try to retrive the session
variable:
> ---
> Warning: Undefined index: node in c:\program files\apache
> group\apache\htdocs\wan\getglobal.php on line 17
> ---
>
> Any ideas why?
>
> (Here's the exact code I've got)
> [sessions.php]
> 
> 
> 
> A test
> 
> 
>
>   function sessionSetNode ($node_id) {
>  return ($_SESSION['node'] = $node_id);
>  }
>
>  sessionSetNode("10.2");
> ?>
>
> 
> 
>
> [getglobal.php]
> 
> 
> 
> A test
> 
> 
>
> if (!empty($_SESSION)) {
>extract($_SESSION);
>} else if (!empty($HTTP_SESSION_VARS)) {
>extract($HTTP_SESSION_VARS);
>}
>
>function sessionGetNode () {
>  return $_SESSION['node'];
>}
>
>$n = sessionGetNode();
>echo ("Node is $n.");
> ?>
>
> 
> 
>
>
> TIA,
> Leston
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re[2]: [PHP] sessions help

2002-06-13 Thread Leston Drake

At 03:32 PM 6/13/2002, you wrote:
>Thanks to Julie and Stuart for helping me.
>
>With your direction, I got rid of the warning about the headers by putting 
>the session_start() at the beginning of the file.
>
>Now I get a different sort of error when I try to retrive the session 
>variable:
>---
>Warning: Undefined index: node in c:\program files\apache 
>group\apache\htdocs\wan\getglobal.php on line 17
>---
>
>Any ideas why?
>
>(Here's the exact code I've got)

This is the code, w/o formatting, and w/o the html tags. Sorry about the 
formatting in the email

>[sessions.php]
>
>$node_id); } sessionSetNode("10.2"); ?>
>[getglobal.php]
>
>(!empty($HTTP_SESSION_VARS)) { extract($HTTP_SESSION_VARS); } function 
>sessionGetNode () { return $_SESSION['node']; } $n = sessionGetNode(); 
>echo ("Node is $n."); ?>
>
>TIA,
>Leston
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re[2]: [PHP] sessions help

2002-06-13 Thread Leston Drake

Thanks to Julie and Stuart for helping me.

With your direction, I got rid of the warning about the headers by putting 
the session_start() at the beginning of the file.

Now I get a different sort of error when I try to retrive the session variable:
---
Warning: Undefined index: node in c:\program files\apache 
group\apache\htdocs\wan\getglobal.php on line 17
---

Any ideas why?

(Here's the exact code I've got)
[sessions.php]



A test








[getglobal.php]



A test









TIA,
Leston


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re[2]: [PHP] sessions help

2002-06-13 Thread Leston Drake

It's the 1st line after LD> I just tried adding session_start() to the beginning of both files. 
>When I
>LD> load Doc 1, I get this warning twice(!):
>
>LD> Warning: Cannot send session cache limiter - headers already sent (output
>LD> started at c:\program files\apache 
>group\apache\htdocs\wan\sessions.php:7)
>LD> in c:\program files\apache group\apache\htdocs\wan\sessions.php on line 9
>
>LD> Same warning for Doc 2.
>
>
>That just means you put it in the wrong place.  It has to go before
>any (and "any" means ANY) output.
>
>
>- Julie
>
>--> Julie Meloni
>--> [EMAIL PROTECTED]
>--> www.thickbook.com
>
>Find "Sams Teach Yourself MySQL in 24 Hours" at
>http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re[2]: [PHP] sessions help

2002-06-13 Thread Stuart Dallas

On Thursday, June 13, 2002 at 10:04:05 PM, you wrote:

> I just tried adding session_start() to the beginning of both files. When I 
> load Doc 1, I get this warning twice(!):

> Warning: Cannot send session cache limiter - headers already sent (output 
> started at c:\program files\apache group\apache\htdocs\wan\sessions.php:7) 
> in c:\program files\apache group\apache\htdocs\wan\sessions.php on line 9

> Same warning for Doc 2.

In that case the call to session_start() is not at the beginning of the files.
By that I mean the first line in both files should be...



Before any HTML or other PHP code. This is because it sets a cookie which needs
to be able to send an HTTP header which can only be done before any output is
generated (unless output buffering is enabled). According to the error, the
call to session_start() is on line 9 but output was generated on line 7.

-- 
Stuart


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re[2]: [PHP] sessions help

2002-06-13 Thread Julie Meloni

LD> I just tried adding session_start() to the beginning of both files. When I 
LD> load Doc 1, I get this warning twice(!):

LD> Warning: Cannot send session cache limiter - headers already sent (output 
LD> started at c:\program files\apache group\apache\htdocs\wan\sessions.php:7) 
LD> in c:\program files\apache group\apache\htdocs\wan\sessions.php on line 9

LD> Same warning for Doc 2.


That just means you put it in the wrong place.  It has to go before
any (and "any" means ANY) output.


- Julie

--> Julie Meloni
--> [EMAIL PROTECTED]
--> www.thickbook.com

Find "Sams Teach Yourself MySQL in 24 Hours" at
http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php