Eval var from query

This is a discussion on Eval var from query within the PHP General forums, part of the PHP Programming Forums category; How can I evaluate a var that is from a text field of a database? Example: MySQL field `name` = hi ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-14-2003
Shawn McKenzie
 
Posts: n/a
Default Eval var from query

How can I evaluate a var that is from a text field of a database? Example:

MySQL field `name` = hi my name is $name

In my script I have:

$name = "Shawn";

After fetching a query result as an associative array I have the contents of
the `name` field in $data

If I echo $data I get: hi my name is $name

I would like to get: hi my name is Shawn

TIA,
Shawn


Reply With Quote
  #2 (permalink)  
Old 07-14-2003
David Nicholson
 
Posts: n/a
Default Re: [PHP] Eval var from query

Hello,


This is a reply to an e-mail that you wrote on Mon, 14 Jul 2003 at 20:03,
lines prefixed by '>' were originally written by you.
> How can I evaluate a var that is from a text field of a database?
> Example:
> MySQL field `name` = hi my name is $name
> In my script I have:
> $name = "Shawn";
> After fetching a query result as an associative array I have the
> contents of
> the `name` field in $data
> If I echo $data I get: hi my name is $name
> I would like to get: hi my name is Shawn


Use eval($data)

See http://uk.php.net/eval for more info.

All the best,

David.

--
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

Professional Web Development by David Nicholson
http://www.djnicholson.com/

QuizSender.com - How well do your friends actually know you?
http://www.quizsender.com/
(developed entirely in PHP)
Reply With Quote
  #3 (permalink)  
Old 07-14-2003
Shawn McKenzie
 
Posts: n/a
Default Re: Eval var from query

eval($data)

returns Parse error: parse error, unexpected T_STRING in
C:\apps\apache2\htdocs\test\query.php(23) : eval()'d code on line 1

Thanks!
Shawn

"Shawn McKenzie" <nospam@mckenzies.net> wrote in message
news:20030714190325.34064.qmail@pb1.pair.com...
> How can I evaluate a var that is from a text field of a database?

Example:
>
> MySQL field `name` = hi my name is $name
>
> In my script I have:
>
> $name = "Shawn";
>
> After fetching a query result as an associative array I have the contents

of
> the `name` field in $data
>
> If I echo $data I get: hi my name is $name
>
> I would like to get: hi my name is Shawn
>
> TIA,
> Shawn
>
>



Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:01 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0