gpt4 book ai didi

php - 将ckeditor html代码插入数据库

转载 作者:行者123 更新时间:2023-11-29 05:23:30 25 4
gpt4 key购买 nike

我正在尝试将 ckeditor 文本插入数据库,我能够以 html 格式打印代码,同时将其插入数据库,我得到了休闲错误

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 'table' at line 1

INDEX.PHP

<html>
<head>
<script type="text/javascript" src="ckeditor/smaple.js"></script>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
</head>
<body>
<form action="action.php" method="post">
<textarea rows="20" cols="70" class="ckeditor" id="editor1" name="test1"></textarea>
<input type="submit" value="save">
</form>
</body>
</html>

action.php

<?php
echo strip_tags($_POST['test1']);
$content = $_POST['test1'];
mysql_connect("localhost","root","");
$conn = mysql_select_db("test");
$query = "INSERT INTO table VALUES('','one',mysql_real_escape_string($content)";
echo $query;
if(mysql_query($query))
{
echo "inserted";
}
else
{
mysql_error();
}
$display = "select * from table";
$res = mysql_query($display);
if($res)
echo "true";
else
echo mysql_error();
while ($result = mysql_fetch_array($res)) {
echo $res['content'];
}
?>

请帮帮我

最佳答案

将行编辑为:

$query = "INSERT INTO myTableName VALUES('','one','".mysql_real_escape_string($content)."'";

并确保您使用正确的表名值代替 myTableName...

关于php - 将ckeditor html代码插入数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22904776/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com