|
-
Oct 15th, 2002, 05:49 AM
#1
Thread Starter
Addicted Member
Resolving \$variables in a PHP string *RESOLVED*
I'm pulling a piece of SQL code from a field in a database. The code that I'm getting back contains PHP variable place holders. For example the data I get back from the database might be something like:
SELECT * FROM table WHERE field=$variablename
I would then want to run this SQL, but obviously I need $variablename to be replaced with the value of the variable. At the moment it's as if the code I get back is really:
SELECT * FROM table WHERE field=\$variablename
So the code that I get back and run against the database doesn't get filled with the values of any $ style variables that might be in it.
Is there a function or something that will loop through the SQL replacing any variables with their values?
Last edited by mralston; Oct 15th, 2002 at 07:56 AM.
-
Oct 15th, 2002, 07:55 AM
#2
Thread Starter
Addicted Member
eval("\$sql=\"SELECT * FROM table WHERE field=$variablename\";");
Does the trick.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|