Don't quite understand why this works, but it does:

    /* Escape quotes in sql_query so our header_id gets evaluated */
    eval("\$myrow[2] = \"$myrow[2]\";");

What's the deal with the leading backslash in ' eval("\$myrow[2] '?

Does eval() tell php to evaluate the string as php code; i.e. text without
quotes?

Thanks for the help.......

--Noah


----- Original Message -----
From: "Maxim Maletsky" <[EMAIL PROTECTED]>
To: "CF High" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Friday, January 24, 2003 9:59 AM
Subject: Re: [PHP] Evaluate PHP var in stored sql statement?


>
> use eval()
>
> www.php.net/eval
>
>
> --
> Maxim Maletsky
> [EMAIL PROTECTED]
>
>
>
> "CF High" <[EMAIL PROTECTED]> wrote... :
>
> > Hey all.
> >
> > I need to find out how to get PHP to evaluate a PHP variable stored in
our
> > MySql database.
> >
> > Currently the variable is being read as a string; i.e. select * from
table
> > where column = $myrow[0] -- instead of evaluating $myrow[0] as a
variable.
> >
> >
> > The SQL statement is retrieved in the first call to dbConnect (see code
> > below)
> >
> >
> >
> > dbConnect("SELECT header_id, header, sql_query FROM cat_headers WHERE
> > section_id = $_REQUEST[section_id] order by header");
> >
> >       $set = $result;   /* Give initial result set a unique name */
> >
> >       while ($myrow = mysql_fetch_row($set)) {
> >
> >             echo(Display the header title here);
> >
> >
> >           dbConnect($myrow[2]);      /*  $myrow[2] is the sql_query
gotten
> > from the first dbConnect() call  */
> >
> >              $set1 = $result;    /* Give next result set a unique name
*/
> >
> >             while ($myrow = mysql_fetch_row($set1)) {
> >
> >                 echo(Display category rows here);
> >
> >             }
> >
> >       }
> >
> > --
> >  Any leads/suggestions much appreciated..........
> >
> > --Noah
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to