Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Problems with function "eval" in combination with

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Problems with function "eval" in combination with

Postby ccg » Fri May 09, 2003 11:40 pm

Hello,
I would check a "variable" variable whether it´s isset..

eval("if(!empty(\$cs_song_".$side."))");
{
echo"bla";
}
else
{
echo"blu";
}

For Example, the variable can be $cs_song_a

Why doesn´t that function? I ordinary get the following error:
Parse error: parse error, unexpected T_ELSE in ..... on line .....


I would be pleased to hear from you. Thanks

Andre
ccg
New php-forum User
New php-forum User
 
Posts: 3
Joined: Fri May 09, 2003 11:32 pm

Postby pootergeist » Fri May 09, 2003 11:55 pm

I'd guess it would be the if that is fouling - maybe assign a variable to the !empty and if that

eval("\$test_var = (!empty(\$cs_song_".$side.")) ? true : false;");
if($test_var == true)
{
// do stuff

am just guessing though
pootergeist
New php-forum User
New php-forum User
 
Posts: 191
Joined: Wed Jan 29, 2003 7:11 am
Location: UK

Postby ccg » Sat May 10, 2003 12:04 am

I'm pleased at your quickly reply :D
Now, i have an other problem *ggg*

eval("\$test_var = !empty(\$cs_song_".$side.") ? true : false;");
if($test_var == true)
{
$i=1;
while($i<=eval("\$cs_song_".$side.""))
{
echo"$side$i: <INPUT name=\"song_".$side."[]\"><BR>";
$i++;
}
}
The while function do problems...
ccg
New php-forum User
New php-forum User
 
Posts: 3
Joined: Fri May 09, 2003 11:32 pm

an other problem with eval

Postby ccg » Sat May 10, 2003 5:59 am

hi, now i have an other problem with the function eval.

i would be register a variable with eval.

eval("session_register(ssong_".$side."[".$i."]);");

but php dont like the [ ]

What can i do? \[it doesnt matter.

Andre
ccg
New php-forum User
New php-forum User
 
Posts: 3
Joined: Fri May 09, 2003 11:32 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.