[PHP] Can I do this? If so why wont it work

2004-01-16 Thread Alex Hogan
I am wanting to read in several session values at once.

 

This is what I have so far;

 

$_SESSION['obj[1]'] = $_REQUEST['txtObj1'];

$_SESSION['obj[2]'] = $_REQUEST['txtObj2'];

$_SESSION['obj[3]'] = $_REQUEST['txtObj3'];

$_SESSION['obj[4]'] = $_REQUEST['txtObj4'];

$_SESSION['obj[5]'] = $_REQUEST['txtObj5'];

 

$i = 1;

while ($i = 5) {

$obj_ar[$i] = $_SESSION['obj[$i]']$i++;

}

 

I keep getting this error;

Parse error: parse error, unexpected T_VARIABLE in mypage.php on line 24 

 

Where am I making the mistake?

 

alex hogan

 



** 
The contents of this e-mail and any files transmitted with it are 
confidential and intended solely for the use of the individual or 
entity to whom it is addressed.  The views stated herein do not 
necessarily represent the view of the company.  If you are not the 
intended recipient of this e-mail you may not copy, forward, 
disclose, or otherwise use it or any part of it in any form 
whatsoever.  If you have received this e-mail in error please 
e-mail the sender. 
** 




Re: [PHP] Can I do this? If so why wont it work

2004-01-16 Thread Jake McHenry

- Original Message - 
From: Alex Hogan [EMAIL PROTECTED]
To: PHP General list [EMAIL PROTECTED]
Sent: Friday, January 16, 2004 4:20 PM
Subject: [PHP] Can I do this? If so why wont it work


 I am wanting to read in several session values at once.
 
  
 
 This is what I have so far;
 
  
 
 $_SESSION['obj[1]'] = $_REQUEST['txtObj1'];
 
 $_SESSION['obj[2]'] = $_REQUEST['txtObj2'];
 
 $_SESSION['obj[3]'] = $_REQUEST['txtObj3'];
 
 $_SESSION['obj[4]'] = $_REQUEST['txtObj4'];
 
 $_SESSION['obj[5]'] = $_REQUEST['txtObj5'];
 
  
 
 $i = 1;
 
 while ($i = 5) {
 
 $obj_ar[$i] = $_SESSION['obj[$i]']$i++;
 
 }
 
  
 
 I keep getting this error;
 
 Parse error: parse error, unexpected T_VARIABLE in mypage.php on line 24 
 
  
 
 Where am I making the mistake?
 
  
 
 alex hogan
 
  
 
 
 
 ** 
 The contents of this e-mail and any files transmitted with it are 
 confidential and intended solely for the use of the individual or 
 entity to whom it is addressed.  The views stated herein do not 
 necessarily represent the view of the company.  If you are not the 
 intended recipient of this e-mail you may not copy, forward, 
 disclose, or otherwise use it or any part of it in any form 
 whatsoever.  If you have received this e-mail in error please 
 e-mail the sender. 
 ** 
 
 
 



What is on line 24?



Try this:

while ($i = 5) {
$obj_ar[$i] = $_SESSION['obj[$i]'];
$i++;
}


Jake

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



RE: [PHP] Can I do this? If so why wont it work

2004-01-16 Thread Alex Hogan

Line 24 is: $obj_ar[$i] = $_SESSION['obj[$i]']$i++;


Alex

 -Original Message-
 From: Jake McHenry [mailto:[EMAIL PROTECTED]
 Sent: Friday, January 16, 2004 3:31 PM
 To: Alex Hogan
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP] Can I do this? If so why wont it work
 
 
 - Original Message -
 From: Alex Hogan [EMAIL PROTECTED]
 To: PHP General list [EMAIL PROTECTED]
 Sent: Friday, January 16, 2004 4:20 PM
 Subject: [PHP] Can I do this? If so why wont it work
 
 
  I am wanting to read in several session values at once.
 
 
 
  This is what I have so far;
 
 
 
  $_SESSION['obj[1]'] = $_REQUEST['txtObj1'];
 
  $_SESSION['obj[2]'] = $_REQUEST['txtObj2'];
 
  $_SESSION['obj[3]'] = $_REQUEST['txtObj3'];
 
  $_SESSION['obj[4]'] = $_REQUEST['txtObj4'];
 
  $_SESSION['obj[5]'] = $_REQUEST['txtObj5'];
 
 
 
  $i = 1;
 
  while ($i = 5) {
 
  $obj_ar[$i] = $_SESSION['obj[$i]']$i++;
 
  }
 
 
 
  I keep getting this error;
 
  Parse error: parse error, unexpected T_VARIABLE in mypage.php on line 24
 
 
 
  Where am I making the mistake?
 
 
 
  alex hogan
 
 
 
 
 
  **
  The contents of this e-mail and any files transmitted with it are
  confidential and intended solely for the use of the individual or
  entity to whom it is addressed.  The views stated herein do not
  necessarily represent the view of the company.  If you are not the
  intended recipient of this e-mail you may not copy, forward,
  disclose, or otherwise use it or any part of it in any form
  whatsoever.  If you have received this e-mail in error please
  e-mail the sender.
  **
 
 
 
 
 
 
 What is on line 24?
 
 
 
 Try this:
 
 while ($i = 5) {
 $obj_ar[$i] = $_SESSION['obj[$i]'];
 $i++;
 }
 
 
 Jake


** 
The contents of this e-mail and any files transmitted with it are 
confidential and intended solely for the use of the individual or 
entity to whom it is addressed.  The views stated herein do not 
necessarily represent the view of the company.  If you are not the 
intended recipient of this e-mail you may not copy, forward, 
disclose, or otherwise use it or any part of it in any form 
whatsoever.  If you have received this e-mail in error please 
e-mail the sender. 
** 




RE: [PHP] Can I do this? If so why wont it work

2004-01-16 Thread Alex Hogan
Tried it now I get;

Parse error: parse error, unexpected T_VARIABLE in mypage.php on line 22

Line 22 is $i++;

 Try this:
 
 while ($i = 5) {
 $obj_ar[$i] = $_SESSION['obj[$i]'];
 $i++;
 }


** 
The contents of this e-mail and any files transmitted with it are 
confidential and intended solely for the use of the individual or 
entity to whom it is addressed.  The views stated herein do not 
necessarily represent the view of the company.  If you are not the 
intended recipient of this e-mail you may not copy, forward, 
disclose, or otherwise use it or any part of it in any form 
whatsoever.  If you have received this e-mail in error please 
e-mail the sender. 
** 




Re: [PHP] Can I do this? If so why wont it work

2004-01-16 Thread John W. Holmes
Alex Hogan wrote:
I am wanting to read in several session values at once.

 

This is what I have so far;

 

$_SESSION['obj[1]'] = $_REQUEST['txtObj1'];

$_SESSION['obj[2]'] = $_REQUEST['txtObj2'];

$_SESSION['obj[3]'] = $_REQUEST['txtObj3'];

$_SESSION['obj[4]'] = $_REQUEST['txtObj4'];

$_SESSION['obj[5]'] = $_REQUEST['txtObj5'];

 

$i = 1;

while ($i = 5) {

$obj_ar[$i] = $_SESSION['obj[$i]']$i++;

}
I keep getting this error;
Parse error: parse error, unexpected T_VARIABLE in mypage.php on line 24 
Well, first your error is because you have $i++ on that last line. It 
should be separated like someone else mentioned. Second, using 
['obj[$i]'] as the key is not going to work because $i is not 
evaluated between single quotes.

Third, you really need to change how you do all of this and understand 
arrays a little better.

First thing to do is instead of naming things txtObj1 and txtObj2, 
etc, name them txtObj[]. Name every one of them that. Now, when the 
form is submitted, you'll have a $_REQUEST['txtObj'] array containing 
all of your data. $_REQUEST['txtObj'][0] will be the first value, 
$_REQUEST['txtObj'][1] will be the second, etc.

To save that in the session, you can simply do:

$_SESSION['txtObj'] = $_REQUEST['txtObj'];

Now, $_SESSION['txtObj'][0] is the first one, $_SESSION['txtObj'][1] is 
the second, etc.

Any time you're naming things _1, _2, _3, etc, you're doing it the hard 
way instead of using an array.

Hope this helps.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals  www.phparch.com

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


RE: [PHP] Can I do this? If so why wont it work

2004-01-16 Thread Alex Hogan
Thanks..

 -Original Message-
 From: John W. Holmes [mailto:[EMAIL PROTECTED]
 Sent: Friday, January 16, 2004 4:29 PM
 To: Alex Hogan
 Cc: PHP General list
 Subject: Re: [PHP] Can I do this? If so why wont it work
 
 Alex Hogan wrote:
  I am wanting to read in several session values at once.
 
 
 
  This is what I have so far;
 
 
 
  $_SESSION['obj[1]'] = $_REQUEST['txtObj1'];
 
  $_SESSION['obj[2]'] = $_REQUEST['txtObj2'];
 
  $_SESSION['obj[3]'] = $_REQUEST['txtObj3'];
 
  $_SESSION['obj[4]'] = $_REQUEST['txtObj4'];
 
  $_SESSION['obj[5]'] = $_REQUEST['txtObj5'];
 
 
 
  $i = 1;
 
  while ($i = 5) {
 
  $obj_ar[$i] = $_SESSION['obj[$i]']$i++;
 
  }
  I keep getting this error;
 
  Parse error: parse error, unexpected T_VARIABLE in mypage.php on line 24
 
 Well, first your error is because you have $i++ on that last line. It
 should be separated like someone else mentioned. Second, using
 ['obj[$i]'] as the key is not going to work because $i is not
 evaluated between single quotes.
 
 Third, you really need to change how you do all of this and understand
 arrays a little better.
 
 First thing to do is instead of naming things txtObj1 and txtObj2,
 etc, name them txtObj[]. Name every one of them that. Now, when the
 form is submitted, you'll have a $_REQUEST['txtObj'] array containing
 all of your data. $_REQUEST['txtObj'][0] will be the first value,
 $_REQUEST['txtObj'][1] will be the second, etc.
 
 To save that in the session, you can simply do:
 
 $_SESSION['txtObj'] = $_REQUEST['txtObj'];
 
 Now, $_SESSION['txtObj'][0] is the first one, $_SESSION['txtObj'][1] is
 the second, etc.
 
 Any time you're naming things _1, _2, _3, etc, you're doing it the hard
 way instead of using an array.
 
 Hope this helps.
 
 --
 ---John Holmes...
 
 Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
 
 php|architect: The Magazine for PHP Professionals - www.phparch.com
 
 
 



** 
The contents of this e-mail and any files transmitted with it are 
confidential and intended solely for the use of the individual or 
entity to whom it is addressed.  The views stated herein do not 
necessarily represent the view of the company.  If you are not the 
intended recipient of this e-mail you may not copy, forward, 
disclose, or otherwise use it or any part of it in any form 
whatsoever.  If you have received this e-mail in error please 
e-mail the sender. 
**