I have a form for a blog post and whenever I have a single quote (for example, that's) the SQL insert code breaks. I have tried using mysql_real_escape_string:
$Description = mysql_real_escape_string($_POST['Description']);
But this doesn't work. I tried using htmlspecialchars() too, but for these posts I need to be able to use HTML code for adding links and images.
I updated the SQL code to like a guide said to do and still I didn't work. Then I can update it if there are no single quotes, so the code does work, but the single quotes are causing lots of trouble
$SQL = "UPDATE Posts SET Title = '$Title',LinkTitle = '$LinkTitle',MainPicture = '$MainPic',Description ='".$Description."',Maintext = '$Main',Type = '$SubCategory',Featured = '$Featured'
,category = '$Category',thumbnail='$thumb'
WHERE ID = '$id'";
Fix
Thanks to Gaucho for the solution the problem was I was using mysqli to connect to the database. changing the connection code to normal mysql_connect fixed the problem.