0
我收到此錯誤信息:如何使用Textarea將此數據存儲在數據庫中?
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Hello World'; ?>')' at line 1
我期待存儲以下數據:
<?php echo 'Hello World'; ?>
這是我的代碼:
if(isset($_POST['submit'])){
$post = $_POST['post'];
$tqs = "INSERT INTO ttn03 (post) VALUES ('$post')";
$tqr = mysqli_query($dbc, $tqs) or die(mysqli_error($dbc));
echo "The data has gotten successfully added.";
}
使用這兩個沒有爲工作me:
htmlspecialchars();
htmlentities();
這是HTML表單:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<textarea name="post" value=""></textarea>
<br/>
<input type="submit" name="submit"/>
</form>
數據庫歸類是:
utf8_unicode_ci
這是我的頭:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
有什麼建議?
** STOP投擲的數據。 **我不知道是誰給了你直接在SQL中拋出'$ post'數據的想法,但他應該被槍殺。 – Christian 2014-10-04 09:59:33