Reputation: 502
I'm trying to do this, but it returns null?
$query_1=$field_name[0]."='{".$field_value[0]."}'";
and then
getType = mysql_query("SELECT * FROM wines WHERE $query_1") or die(mysql_error());
while if i do like this:
$getType = mysql_query("SELECT * FROM wines WHERE $field_name[0]='{$field_value[0]}'") or die(mysql_error());
it works fine.
is this even possible, or am I missing something too obvious? thank you in advance!
Upvotes: 0
Views: 4177
Reputation: 100205
This works for me:
$field_name[0] = "test"; $field_value[0] = "someting"; $query_1=$field_name[0]."='".$field_value[0]."'"; echo ("SELECT * FROM wines WHERE $query_1") or die(mysql_error());
Hope it helps
Upvotes: 1
Reputation: 8101
You are building it the wrong way. You should never use curly brackets (or any other string) in a SQL query. Concatenate your query instead.
Like this:
$query_1=$field_name[0]."='".$field_value[0]."'";
and oh, you missed a $ before your query, thats why its null.
Upvotes: 1