Hi;
I'm trying to make my site more efficient by calling queries from a table rather than hard-coding them into each page.
IE. say I have a mysql table to store queries with the fields ID, SQLname, SQL.
SAMPLE DATA RECORD
ID: 1
SQLname: Test Query
SQL: SELECT * FROM TABLE2 WHERE USER='$USER'
(Note, the SQL field is defined as a TEXT field).
So in the script I post the value of $USER (ie. $USER='joe'😉
When I try to call and run the script in the same page, the query does not work, because it is trying to run, literally:
"SELECT FROM TABLE2 WHERE USER='$USER' " instead of "SELECT FROM TABLE2 WHERE USER='joe ".
I suppose it something where I have to use some special characters or something around the string or the variable name that I save in the SQL field?
Anybody got a clue for me on this one? Thanks.