Re: Problem : replacing of variable with it's value in a string(query)

From: Date: Wed, 21 Jun 2000 00:12:27 +0000
Subject: Re: Problem : replacing of variable with it's value in a string(query)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-2408@lists.php.net to get a copy of this message
In article <8icssg$fik$1@toye.php.net>, bs@corepeople.dk ("Bobby Singh") wrote: > I have my sql-queries saved in a database. Every time I want to run a query > I fetch the desired query from the db. It runs fine. The problem is when the > query is dynamic. Here is one of my queries. > > SELECT * FROM DataTypes WHERE type = '$type' > > I would like the variable to be replaced with its value before the query is > executed. How do I do that it. I have tried the query with both the single, > double and no quotes. No luck! Try something like this: $sql = "select * from DataTypes where type = '\$type'"; $realsql = eval("\"$sql\""); echo "SQL: ", $sql, "<BR>\n"; echo "Real: ", $realsql, "<BR>\n"; -- Richard Lynch | If this was worth $$$ to you, buy a CD US Customer Support Director | from one of the artists listed here: Zend Technologies USA | http://www.L-I-E.com/artists.htm http://www.zend.com | (this has nothing to do with Zend, duh!)

« previous php.general (#2408) next »