Hi,
I have a MySQL table from which I am pulling data (varchar) and inserting it into a variable(PHP).
the relevant code looks like this:
$sub_query = "SELECT * FROM <table name> where ($order = '$main_sort'); $order is set earlier in the script
$sub_result = mysql_query(sub_query);
# the following is where it breaks
if (mysql_num_rows(sub_result)>0)
{
stuff here
}
It all works fine unless there is an apostrophe in the varchar data which is retrieved into sub_query. And I can't manage to escape the apostrophe. I've tried everything in the manual that I can find, but all of the characters print. It works but I end up with something like "Beckie''s Fanny' printing to the html output. If I eliminate the apostrophe the problem goes away.
Thanks
John