Re: Eval error

From: Date: Wed, 15 Aug 2001 20:03:57 +0000
Subject: Re: Eval error
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-62899@lists.php.net to get a copy of this message
lots of things: 1) variables in single-quoted strings aren't evaluated so you don't need to escape the $ in $email 2) php uses . not + for concatenation. 3) try it like this: eval('$email = $email_'.$i.';'); or eval("\$email = \$email_$i;"); 4) you can save yourself the trouble by using arrays as field names: <input name="email[1]"> 5) RTFM! that's what its there for. On Wed, 15 Aug 2001 15:15:09 -0300, Felipe Coury (fcoury@creation.com.br) wrote: >Hi, > >I am a beginner in PHP and I am trying to do the following: I have a >form in >a page that has 3 fields: email_1, email_2 and email_3. I am trying >to send >e-mail to those people, if the fields are filled. Relevant part of >code: ><?php >for ($i = 1; $i <= 6; $i++) { > $eval = '\$email = \$email_' + $i + ';'; > eval( $eval ); > echo $email; >} >?> > >The code complains about an error in line eval( $eval );: > >Parse error: parse error in >/home/httpd/htdocs/hthcombr/cgi-local/envia.php(19) : eval()'d code >on line >1 > >Can anyone please help me? > >Regards, > >Felipe Coury > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >For additional commands, e-mail: php-general-help@lists.php.net >To contact the list administrators, e-mail: php-list- >admin@lists.php.net

« previous php.general (#62899) next »