I have tables that have to have all kinds of punctuation in them. I am able to select the tables just fine using backticks (), such as in this query:
mysql_query("select plant_source from$chemical`");
however, when I try to select them in a query such as this:
mysql_query("select * from compounds where chemical='$allchems[$c]' ")
$allchems is a an array of strings created from these troublesome tables. For example, $allchems includes strings such as:
formic-acid
eleutheroside-b-4
2,,3,3',4,4',5,7-heptahydroxyflavanbioside
These do not appear in the results, only chemicals that DO NOT have any punctuation (apigenin, fiber, protein, magnesium)
Also to add one more thing: When I run a query such as this:
select from compounds where chemical="2,,3,3',4,4',5,7-heptahydroxyflavanbioside"
The query works. Now, it seems obvious to me that the problem is that the chemical contained in double-quotes works as a query. However, using php, I cannot use double quotes in a query, or else it dies with an error. How do I use double-quotes in a php script.. For example:
$result3=mysql_query("select from compounds where chemical="$allchems[$c]"");
Is what I want, but won't work.