我正在尝试将撇号添加到表单中,然后将其保存到数据库中,但是添加撇号时表单不会保存。
这是我的代码:
<?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);
当我在表单中添加撇号以将其保存到数据库时,出现以下错误
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use