Re: Problem : replacing of variable with it's value in a string(query)
| From: | Zak Greant | Date: | Fri, 16 Jun 2000 16:00:31 +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-2082@lists.php.net to get a copy of this message | ||
At 11:45 AM 6/16/00 +0200, 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!Hi Bob, Something like: $query = "SELECT * FROM DataTypes WHERE type = '$type'"; $query_handle = mysql_query ($query); If it doesn't, then I usually drop a print statement in front of the $query line. This lets me see exactly what is generated for the query. HTH, Zak Greant Creative Director Nucleus Information Service Inc. "I am rather like a mosquito in a nudist camp: I know what I ought to do, but I don't know where to begin." - Stephen Bayne