有人可以請幫忙,我有一個文本區域的形式,用戶可以鍵入內容並提交它,然後內容被存儲在MySQL表中。在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() ?>
您正在使用[an **過時的**數據庫API](http://stackoverflow.com/q/12859942/19068)並應使用[現代替換](http://php.net/)手動/ EN/mysqlinfo.api.choosing.php)。 – Quentin 2013-02-16 18:00:49