I am storing user's liked pages from facebook in my postgres database, one of them being Sinead O'Connor's page. It seems like when it gets to the apostrophe, it terminates the query beacuse the apostrophes match and therefore results in an error:
$json_likes=json_encode($likes);
echo $json_likes;
$query = "UPDATE public.account_recover_users SET user_likes='$json_likes' WHERE user_mail='$email'";
$result = pg_query($query);
if(!$result)
exit('{ "status": false }');
else exit('{ "status": true }');
Now what I get here is :
Warning: pg_query() [<a href='function.pg-query'>function.pg-query</a>]: Query failed: ERROR: syntax error at or near "Connor" LINE 1: ...l","page_id":"243440865683470"},{"name":"Sinead O'Connor","p...
Any idea how should I handle this? My app's users might have all sorts of charachters in their liked pages.