有人可以帮忙吗,我有一个文本区域表单,用户可以在其中输入内容并提交,然后内容将存储在 mysql 表中。
我遇到的问题是,每当用户键入撇号 ' 时,都会插入一个/,而我想删除/。
我的专栏是 utf8_general_ci 格式(长文本),我在这里使用的是正确的格式类型吗?
这也是我的代码,也许我需要在 mysql 中放入一些东西?
请有人告诉我哪里出了问题,谢谢。
html 表单:
<form action="includes/changebio.php" method="post" id="form1">
<textarea id="bio" style="width: 448px;
margin-top:3px;
text-align:left;
margin-left:-2px;
height: 120px;
resize: none;
border: hidden;" 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 ob_start(); ?>
<?php
require_once("session.php");
require_once("functions.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 ='".mysql_real_escape_string($bio)."' WHERE id=".$_SESSION['user_id']."");
}
header("Location: {$_SERVER['HTTP_REFERER']}");
?>
<?php ob_end_flush() ?>
最佳答案
有2种可能的情况
- 你有魔法引号。 Turn them off.
- 某种全部清理功能会对您的所有输入数据运行。摆脱它。
关于php - 去掉mysql中的撇号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14913349/