我試圖寫入數據庫使用CKEditor ..當我按提交它死亡,並說本地主機當前無法處理此請求。 HTTP錯誤500從CKEDITOR寫入數據庫
我只想將textarea保存到數據庫中的一行中,以便我可以將該行讀到另一頁上。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="robots" content="noindex, nofollow">
<title>Classic editor replacing a textarea</title>
<script src="http://cdn.ckeditor.com/4.6.0/standard-all/ckeditor.js"></script>
</head>
<body>
<form id="editor1" action="save.php" method="post" >
<textarea cols="80" id="editor1" name="editor1" rows="10">
</textarea>
<p>
<input type="submit" value="Submit">
</p>
</form>
<script>
CKEDITOR.replace('editor1');
</script>
</body>
</html>
PHP腳本
<?php
if(isset($_POST['submit']))
{
// Putting data from form into variables to be manipulated
$text = $_POST['editor1'];
$conn = mysql_connect("localhost","root","root") or die ("Can't connect");
mysql_select_db("managerMessage",$conn);
// Getting the form variables and then placing their values into the MySQL table
mysql_query("INSERT INTO text (textarea) VALUES ("mysql_real_escape_string($text)");
}
?>
**停止**使用不推薦使用的'mysql_ *'API。使用'mysqli_ *'或'PDO'與準備好的語句 – Jens
是否獲得了$ text變量中的ckeditor值? – 2016-11-22 11:08:38
每次使用[mysql_'](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) 數據庫擴展在新代碼 ** [一隻小貓被勒死在世界某個地方](http://2.bp.blogspot.com/-zCT6jizimfI/UjJ5UTb_BeI/AAAAAAAACgg/AS6XCd6aNdg/s1600/luna_getting_strangled.jpg)**它被棄用,並且已經存在了很多年,並且已經消失了永遠在PHP7中。 如果您只是學習PHP,請花些精力學習'PDO'或'mysqli'數據庫擴展。 [開始](http://php.net/manual/en/book.pdo.php) – RiggsFolly