RE: [PHP] *OK, more eval for today

2002-12-19 Thread Ford, Mike [LSS]
> -Original Message-
> From: Alexey Lysenkov [mailto:[EMAIL PROTECTED]]
> Sent: 18 December 2002 19:08
> 
> 
> I am trying to do this:
> 
> $tempVar1 = '\$HTTP_POST_VARS[\"q4_'.$i.'"]';
>   eval("\$tempVar1=\"$tempVar1\";");
> 

Well, you have the answer right there in front of you -- why not just take the 
statement you build and eval(), and write it directly in the PHP thus:

   $tempVar1 = $HTTP_POST_VARS['q4_'.$i];

or

   $tempVar1 = $HTTP_POST_VARS["q4_$i"];

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 



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




RE: [PHP] *OK, more eval for today

2002-12-18 Thread Martin Towell
argh! eval()
try this instead: $temp = ${"php_q3_$i"};
to get it directly from $HTTP_POST_VARS: $temp =
$HTTP_POST_VARS["php_q3_$i"];
simple

HTH
Martin

-Original Message-
From: Alexey Lysenkov [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 19, 2002 6:08 AM
To: [EMAIL PROTECTED]
Subject: [PHP] *OK, more eval for today


I know, it's eval = evil, but I don't see any other way I can check for 120
variables submitted via post, without making a temp variable, assigning a
value of the posted Var and checking for it (and deciding on the further run
of the script). Anyways, I took a classical eval thing and am doing fine
with it. It looks like this:

$temp = "\$php_q3_".$i; // $i is a loop index
eval ("\$temp = \"$temp\";");

works alright. Now, how do I eval directly from the $HTTP_POST_VARS?

I am trying to do this:

$tempVar1 = '\$HTTP_POST_VARS[\"q4_'.$i.'"]';
  eval("\$tempVar1=\"$tempVar1\";");

and am obviously failing. If you know any other way to validate 120-150
variables in a loop and then rewrite the values into the fields (checkboxes,
radios and selects) - should an error had been made - let me know.

Best Regards,
Alex

p.s. you do help! :)

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




Re: [PHP] *OK, more eval for today

2002-12-18 Thread Alexey Lysenkov
It worked for validation! :) Hooray.
Now, I guess, I have to set the same logic for the whole other bumch of
questions God..
Most probably will post here today later again.

Cheers, John!

-Alex



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




Re: [PHP] *OK, more eval for today

2002-12-18 Thread Alexey Lysenkov
am trying



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




RE: [PHP] *OK, more eval for today

2002-12-18 Thread John W. Holmes
> Okay, wait.
> How?
> 
> say, I have a field of checkboxes in 3 columns and 6 rows. I need at
least
> one checked.
> At the moment every checkbox has the name of kind: q3_4_1 , where 4
stands
> for row and 1 for column. Now, how do I name them and loop through
them?
> Plus, if $HTTP_POST_VAR["q3_4_1"] wasn't checked at all, the value is
not
> passed over, right? So I get... null, I believe. So with my eval I
first
> do
> if(isset()) and then go on. How would I I behave in your case?
> Please, John, if you could be even more specific?
> 
> Sweating Alex

Well, you could do it exactly the same way, but with arrays. 

The same way that you name it "q3_4_1", you'd name your elements exactly
like "q3[4][1]", which will give you a $HTTP_POST_VARS['q3'][4][1]
variable. So you just loop through that array and see what's set and
what isn't. It depends on what you do if the are set or not, but you can
do something like this. I'm going to use $_POST for simplicity.

//$_POST['q3']['row']['column'] (reference)
for($row = 0;$row < 6; $row++)
{
  for($col = 0; $col < 3; $col++)
  {
if(isset($_POST['q3'][$row][$col]))
{ echo "Checkbox row: $row, column: $col was checked"; }
else
{ echo "Checkbox row: $row, column: $col was not checked"; }
  }
}

Untesteed, but that should work.

---John Holmes...



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




Re: [PHP] *OK, more eval for today

2002-12-18 Thread Alexey Lysenkov
Okay, wait.
How?

say, I have a field of checkboxes in 3 columns and 6 rows. I need at least
one checked.
At the moment every checkbox has the name of kind: q3_4_1 , where 4 stands
for row and 1 for column. Now, how do I name them and loop through them?
Plus, if $HTTP_POST_VAR["q3_4_1"] wasn't checked at all, the value is not
passed over, right? So I get... null, I believe. So with my eval I first do
if(isset()) and then go on. How would I I behave in your case?
Please, John, if you could be even more specific?

Sweating Alex


"John W. Holmes" <[EMAIL PROTECTED]> wrote in message
001e01c2a6ca$22310e00$7c02a8c0@coconut">news:001e01c2a6ca$22310e00$7c02a8c0@coconut...
> Why not name your form elements php_q3[] and then just loop through the
> array. That would cut the need for eval().
>
> ---John W. Holmes...
>
> PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> today. http://www.phparch.com/
>
> > -Original Message-
> > From: Alexey Lysenkov [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, December 18, 2002 2:08 PM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP] *OK, more eval for today
> >
> > I know, it's eval = evil, but I don't see any other way I can check
> for
> > 120 variables submitted via post, without making a temp variable,
> > assigning a value of the posted Var and checking for it (and deciding
> on
> > the further run of the script). Anyways, I took a classical eval thing
> and
> > am doing fine with it. It looks like this:
> >
> > $temp = "\$php_q3_".$i; // $i is a loop index
> > eval ("\$temp = \"$temp\";");
> >
> > works alright. Now, how do I eval directly from the $HTTP_POST_VARS?
> >
> > I am trying to do this:
> >
> > $tempVar1 = '\$HTTP_POST_VARS[\"q4_'.$i.'"]';
> >   eval("\$tempVar1=\"$tempVar1\";");
> >
> > and am obviously failing. If you know any other way to validate
> 120-150
> > variables in a loop and then rewrite the values into the fields
> > (checkboxes, radios and selects) - should an error had been made - let
> me
> > know.
> >
> > Best Regards,
> > Alex
> >
> > p.s. you do help! :)
>
>



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




RE: [PHP] *OK, more eval for today

2002-12-18 Thread John W. Holmes
Why not name your form elements php_q3[] and then just loop through the
array. That would cut the need for eval().

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/

> -Original Message-
> From: Alexey Lysenkov [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, December 18, 2002 2:08 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] *OK, more eval for today
> 
> I know, it's eval = evil, but I don't see any other way I can check
for
> 120 variables submitted via post, without making a temp variable,
> assigning a value of the posted Var and checking for it (and deciding
on
> the further run of the script). Anyways, I took a classical eval thing
and
> am doing fine with it. It looks like this:
> 
> $temp = "\$php_q3_".$i; // $i is a loop index
> eval ("\$temp = \"$temp\";");
> 
> works alright. Now, how do I eval directly from the $HTTP_POST_VARS?
> 
> I am trying to do this:
> 
> $tempVar1 = '\$HTTP_POST_VARS[\"q4_'.$i.'"]';
>   eval("\$tempVar1=\"$tempVar1\";");
> 
> and am obviously failing. If you know any other way to validate
120-150
> variables in a loop and then rewrite the values into the fields
> (checkboxes, radios and selects) - should an error had been made - let
me
> know.
> 
> Best Regards,
> Alex
> 
> p.s. you do help! :)



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