Re: [PHP] eval problem

2002-07-02 Thread Greg Wineman

You da man. Thanks


"Analysis & Solutions" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Tue, Jul 02, 2002 at 11:19:22PM -0400, Analysis & Solutions wrote:
> >
> > Oops.  Forgot to escape the $:
> >
> > $var = "\$wins_$counter";
>
> Oops.  Forgot my promise to myself to always test things before posting.
> I had a sinking feeling my initial posting would come back to haunt me,
> but I JUST DIDN'T CARE!!! :)  Anyway, here's how this line should read:
>
>  $var = "wins_$counter";
>
> Sorry for the confusion and multiple posts.
>
> --Dan
>
> --
>PHP classes that make web design easier
> SQL Solution  |   Layout Solution   |  Form Solution
> sqlsolution.info  | layoutsolution.info |  formsolution.info
>  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
>  4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409



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




Re: [PHP] eval problem

2002-07-02 Thread Analysis & Solutions

On Tue, Jul 02, 2002 at 11:19:22PM -0400, Analysis & Solutions wrote:
> 
> Oops.  Forgot to escape the $:
> 
> $var = "\$wins_$counter";

Oops.  Forgot my promise to myself to always test things before posting.  
I had a sinking feeling my initial posting would come back to haunt me, 
but I JUST DIDN'T CARE!!! :)  Anyway, here's how this line should read:

 $var = "wins_$counter";

Sorry for the confusion and multiple posts.

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

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




Re: [PHP] eval problem

2002-07-02 Thread Greg Wineman

hmm... I must be doing something wrong.  This is still returning 000






"Analysis & Solutions" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Tue, Jul 02, 2002 at 10:45:27PM -0400, Analysis & Solutions wrote:
>
> >$var = "$wins_$counter";
>
> Oops.  Forgot to escape the $:
>
> $var = "\$wins_$counter";
>
> --Dan
>
> --
>PHP classes that make web design easier
> SQL Solution  |   Layout Solution   |  Form Solution
> sqlsolution.info  | layoutsolution.info |  formsolution.info
>  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
>  4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409



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




Re: [PHP] eval problem

2002-07-02 Thread Greg Wineman

This doesn't seem to work. Here's my demo.



This returns 000, it should return 743




"Analysis & Solutions" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Tue, Jul 02, 2002 at 10:19:59PM -0400, Greg Wineman wrote:
> >
> > He are the variables from my form
> >
> > wins_1=7
> > losses_1=0
> > sort_1=1
> > wins_2=7
> > losses_2=4
> > sort_2=2
> > wins_3=7
> > losses_3=4
> > sort_3=3
> >
> > $counter=1;
> > $wins=eval("\$wins_".$counter);
>
> eval() is overkill and can be dangerous.
>
> I'd use variable variables instead:
>
> $wins = 0;
> for ($counter=1; $counter<=3; $counter++) {
>$var = "$wins_$counter";
>$wins = $wins + $$var;
> }
>
> --Dan
>
> --
>PHP classes that make web design easier
> SQL Solution  |   Layout Solution   |  Form Solution
> sqlsolution.info  | layoutsolution.info |  formsolution.info
>  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
>  4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409



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




Re: [PHP] eval problem

2002-07-02 Thread Analysis & Solutions

On Tue, Jul 02, 2002 at 10:45:27PM -0400, Analysis & Solutions wrote:

>$var = "$wins_$counter";

Oops.  Forgot to escape the $:

$var = "\$wins_$counter";

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

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




Re: [PHP] eval problem

2002-07-02 Thread Analysis & Solutions

On Tue, Jul 02, 2002 at 10:19:59PM -0400, Greg Wineman wrote:
> 
> He are the variables from my form
> 
> wins_1=7
> losses_1=0
> sort_1=1
> wins_2=7
> losses_2=4
> sort_2=2
> wins_3=7
> losses_3=4
> sort_3=3
> 
> $counter=1;
> $wins=eval("\$wins_".$counter);

eval() is overkill and can be dangerous.

I'd use variable variables instead:

$wins = 0;
for ($counter=1; $counter<=3; $counter++) {
   $var = "$wins_$counter";
   $wins = $wins + $$var;
}

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

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




[PHP] eval problem

2002-07-02 Thread Greg Wineman

Hello,

Could someone offer some insight on eval(); I am fairly new at this.

I would like to evaluate numerous variables from a form submission with a
loop, but I can;t even get on to work:

I.e.

He are the variables from my form

wins_1=7
losses_1=0
sort_1=1
wins_2=7
losses_2=4
sort_2=2
wins_3=7
losses_3=4
sort_3=3

I am trying to evaluate the values based on a loop.  Here's my current
method

$counter=1;
$wins=eval("\$wins_".$counter);

$wins should return 7 in this example.  Where am I going wrong?

Any help would be appreciated.

Thanks,
Greg



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