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?