[wp-hackers] single quote #039; issue when querying the DB
autremonde75 at gmail.com
Mon Dec 7 21:18:47 UTC 2009
I am encountering a big problem and I canno't find any "clean"
When a meta_value is saved within the usermeta table, if it contains a
single quote then it is converted to #39;
for instance : tot'o is converted to tot#39;o
Then when you get it back from the DB, it will be tot#039;o (note the
added 0). This is not a problem if you just need to output data.
But when it comes to perform a query with a condition on the
meta_value, then I am lost because when I convert the single quote
with any function like esc_html, it is converted to #039; and not #39;
so if I query on "WHERE meta_value = $myvalue" which contains #039; it
will always fail :(
I could obviously add a function to convert 039 to 39 before sending
to the DB but well, if there is any built in function that does all
the job directly (clean one step conversion from single quote to
#39;), I would rather use it.
More information about the wp-hackers