Try this
eval("\$sql=\"select * from vehicle where company=$company_code\";");

Sheridan Saint-Michel
Website Administrator
FoxJet, an ITW Company
www.foxjet.com


----- Original Message -----
From: "Mark Newnham" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, September 19, 2001 4:34 PM
Subject: RE: [PHP-DB] Storing code in a mysql database


> I've now progressed to the point where I'm not getting eval errors. The
next
> problem is that is doesn't substitute the variable names: so the code
>
> $company_code=1;
>
> eval($sql='select * from vehicle where company=$company_code';");
>
> ends up $sql equal to 'select * from vehicle where company=$company_code'
>
> and not 'select * from vehicle where company=1'
>
> Any clues?
>
> TIA
>
> Mark
>
> > -----Original Message-----
> > From: Mark Newnham [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, September 19, 2001 2:54 PM
> > To: '[EMAIL PROTECTED]'
> > Subject: [PHP-DB] Storing code in a mysql database
> >
> >
> > I'm trying to store SQL code in a blob field in a mysql
> > database, but i'm
> > having a problem.
> >
> > The code looks like this "$sql='select * from vehicle where
> > company=$company_code';";
> >
> > After I retrieve it from the db i eval() it to get the result.
> >
> > I can make this work if i store the code in a variable, but
> > not if i store
> > it in a database table and retrieve it. I am sure i am
> > missing the right
> > combination of addslashes/striplashes etc.
> >
> > can anyone help on this problem?
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail:
> > [EMAIL PROTECTED]
> >
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to