RE: [PHP] PHP3: eval() problem AGAIN
| From: | Grant Walters | Date: | Sun, 22 Oct 2000 05:50:00 +0000 |
| Subject: | RE: [PHP] PHP3: eval() problem AGAIN | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-21623@lists.php.net to get a copy of this message | ||
> > I'm creating generic single record editing forms from within a
> database and
> > want to pass the where clause to MySQL, so...
> >
> > I want to put something like
> >
> > ID='$SessionParms[\"User_ID\"]'
> >
> > into the Mysql database and then build my string
> >
> > $WhereClause = "ID='$SessionParms[\"User_ID\"]'"; // Value
> > Taken From
> > Database
> >
> > eval("\$Query =\" SELECT * FROM Table WHERE \$WhereCluse\";");
> Well, I may have spotted the obvious, or it could just be the email
> message...
> There is no a in the word WhereCluse in the line above.
>
> The line should be something like
> eval("\$Query =\" SELECT * FROM Table WHERE \$WhereClause\";");
>
> HINT: echo the staement and then cut and paste to mysql terminal
> client.. It saves me a lot of time with queries goining astray...
>
> Hope that was all the problem was...
Unfortunately not. I spotted the error myself after I pushed the send
button.
I still have the issue. I've been playing eval(), variable variables and an
assortment of ereg_replace and preg_replace options.
The variable variables looks like my best bet so far although I haven't
managed to get them to work with arrays.
To restate the problem slightly differently:
Put "ID='\$User_ID'" into a field in the database.
I want to retrieve it from the database into a variable called WhereClause
so that it actually says "ID='12345'" rahter than
"ID='$User_ID'".
This is driving me nuts as it is crucial to my whole web structure for
online data entry.
Regards
Grant Walters
Walters & Associates, P O Box 13-043 Johnsonville, Wellington, NEW ZEALAND
Telephone: +64 4 4765175, CellPhone 025488265