I am trying to add an apostrophe into a form which then saves to a Database, however the form will not save when the apostrophe is added.
This is my code:
<?php
$abouttitle=$_POST[abouttitle];
$aboutcontent=$_POST[aboutcontent];
$aboutside=$_POST[aboutside];
$aboutsidetitle=$_POST[aboutsidetitle];
$con= mysql_connect("localhost","XXX","XXX");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("cl49-XXX", $con);
$result =
$aboutcontent = mysql_real_escape_string($aboutcontent);
$abouttitle = mysql_real_escape_string($abouttitle);
$aboutside = mysql_real_escape_string($aboutside);
$aboutsidetitle = mysql_real_escape_string($aboutsidetitle);
$query = "
UPDATE ADMIN
SET aboutcontent='$aboutcontent',
abouttitle='$abouttitle',
aboutside='$aboutside',
aboutsidetitle='$aboutsidetitle'
");
$result = mysql_query($query);
when i add an apostrophe into the form to save it to the DB I get the below error
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use