Jump to content

eval() boolean statement


Uranium-235

Recommended Posts

This has been bugging me.

I'm testing if a list of varibles (from a seperate list)I get from extract() from MySQL query is equal to "Y". Do a boolean compairason for each one (this is from a much larger thing). I'm calling this inside a function call

I keep getting "Parse error: parse error, unexpected $ in /home/thescriptwholedirectoryremoved.php(781) : eval()'d code on line 1"

here is the statement I use:

eval("return (\$" . $key . " == \"Y\")")

when I actually print the evaluated statement in PHP, it prints out as:
return ($carreq == "Y")

which is correct, but, eval gives me an error. please help
Link to comment
Share on other sites

thank you.

can you please explain why I got that error. earlier (before i posted here) I even took out the $ completly just cause I was getting pissed, and it still said "Unexpected $". How could it be unexpected, there was no $ at all.

edit: ahhh, it was the semicolon. I had no idea I would have to put one in there on a bool compairason. I don't for my other ones (of course for those, I was passing them alone as an argument), but appearently you have to for eval with a return statement. Thank you
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.