I am trying to store a json encoded array into a MySQL field. The stored array is in the form:
['value1', 'value2', 'value3']
Then I try and run a query like:
SELECT * FROM mytable WHERE arrayfield
it returns no results. The arrayfield is either blank or contains an array, so I am trying to get the records that only contain an array in that field.
Did you properly escaped your data when inserting/updating with your SQL query (see mysql_real_escape_string and sprintf)? Are magic quotes OFF?
As Machine points out this is rather a bad design since relational databases aren’t meant for that kind of stuff…
Also test these queries:
or
do they both return empty results? If so, check that your INSERT/UPDATE query are working…