I'm saving queries in my DB as strings
here's my code:
$SQLcode="SELECT *
FROM ...
WHERE field="blah blah"
HAVING field2<$x";
$query = "INSERT INTO tblQ (qId, qName, description, SQLcode) VALUES (NULL, '$qName', '$description', '$SQLcode');";
the problem is inserting a string into the $SQLcode, if I do it this way:
$SQLcode= " SELECT * FROM ...WHERE field=' blah blah ' HAVING field2<$x ";
it makes problem with the $query cuz there are ' around the $SQLcode:
$query = "INSERT INTO tblQ (qId, qName, description, SQLcode) VALUES (NULL, '$qName', '$description', '$SQLcode');";
if I do it like this:
$SQLcode='SELECT * FROM ...WHERE field="blah blah" HAVING field2<$x';
then the $x is saved as "$x" and not as the value in it..
is there a way around this craziness? gotta be..!