Uranium-235 Posted July 30, 2006 Share Posted July 30, 2006 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 callI 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 Quote Link to comment Share on other sites More sharing options...
DepretioN Posted July 30, 2006 Share Posted July 30, 2006 [code]return eval("return ($" . $key . " == 'Y');");[/code] Quote Link to comment Share on other sites More sharing options...
Uranium-235 Posted July 30, 2006 Author Share Posted July 30, 2006 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.