有人可以告诉我我做错了什么。我有一个表格,我将数据作为文本插入到 mysql 中,但是当你输入撇号或类似的东西时,它会在其中添加一个 \。
有人可以推荐如何让我的 mysql 允许特殊字符吗?
这是我的html表单:
<form action="includes/changebio.php" method="post" id="form1">
<textarea id="bio" textarea name="bio" data-id="bio" maxlength="710"><?php echo htmlspecialchars($profile['bio']); ?></textarea>
<input type="image" src="assets/img/icons/save-edit.png"class="bio-submit" name="submit" value="submit" id="submit"/>
</form>
我的mysql语句:
<?php
require('_config/connection.php');
?>
<?php
session_start();
include '_config/connection.php';
$bio = $_POST['bio'];
$result = mysql_query("SELECT bio FROM ptb_profiles WHERE id=".$_SESSION['user_id']."");
if(!$result)
{
echo "The username you entered does not exist";
}
else
if($bio!= mysql_result($result, 0))
{
echo "";
$sql=mysql_query("UPDATE ptb_profiles SET bio ='".addslashes($bio)."' WHERE id=".$_SESSION['user_id']."");
}
if($sql)
{
header("Location: {$_SERVER['HTTP_REFERER']}");
}
?>