php将textarea内容上传到mysql表中
我有 html/php 代码,其表单标准设计包括文本区域项目。我找不到将 textarea 内容添加到 mysql 数据库表中的方法。
html/php
<form action="this_file.php" method="POST">
<textarea class="inputcat" type="text" cols="40" rows="5" name="content"></textarea>
<input type="submit" value="upload text" name="submit">
</form>
<?php
//allow sessions to be passed so we can see if the user is logged in
session_start();
//connect to the database so we can check, edit, or insert data to our users table
$con = mysql_connect('localhost', 'user', 'pass') or die(mysql_error());
$db = mysql_select_db('dbname', $con) or die(mysql_error());
if(isset($_POST['submit'])){
//insert the row into the database
$contenido = $_POST['content'];
$SQL = "INSERT INTO `table1` (`ct`) VALUE('" .$contenido. "')"; // syntax corrected here
$result = mysql_query($SQL) or die(mysql_error());
}
?>
非常感谢。
问候。
i have html/php code with form standard desing that includes textarea item. i can't find the way to add textarea content to a table in mysql database.
html/php
<form action="this_file.php" method="POST">
<textarea class="inputcat" type="text" cols="40" rows="5" name="content"></textarea>
<input type="submit" value="upload text" name="submit">
</form>
<?php
//allow sessions to be passed so we can see if the user is logged in
session_start();
//connect to the database so we can check, edit, or insert data to our users table
$con = mysql_connect('localhost', 'user', 'pass') or die(mysql_error());
$db = mysql_select_db('dbname', $con) or die(mysql_error());
if(isset($_POST['submit'])){
//insert the row into the database
$contenido = $_POST['content'];
$SQL = "INSERT INTO `table1` (`ct`) VALUE('" .$contenido. "')"; // syntax corrected here
$result = mysql_query($SQL) or die(mysql_error());
}
?>
thank you very much.
greetings.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许尝试更改:
至:
从我所看到的内容中,没有什么真正浮现在脑海中...
您总是可以这样做:
在最顶部查看提交后页面中到底有什么内容...
Perhaps try changing:
To:
Nothing else really springs to mind from what I can see...
You could always do:
At the very top to see what exactly is coming into the page upon submit....
还将您的查询行更改为此,代码中存在语法错误:
考虑在将数据插入数据库之前查看转义数据,更多信息如下:http://www.php.net/manual/en/book.filter.php
编辑:
也许您还应该看看如何调试 PHP: http://www.ibm.com /developerworks/library/os-debug/ - 这肯定会在将来为您节省大量时间。
Also change your query line to this, there is a syntax error in your code:
Consider looking at escaping data before inserting it into the database, more information here: http://www.php.net/manual/en/book.filter.php
Edit:
Maybe you should also look at how you debug PHP: http://www.ibm.com/developerworks/library/os-debug/ - This will definitely save you a lot of time in the future.