【发布时间】:2012-03-04 07:28:04
【问题描述】:
我有包含 textarea 项的表单标准设计的 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());
}
?>
非常感谢。
问候。
【问题讨论】:
-
更正了您的语法错误...以上内容现在对您有用吗?
-
不,不是。我会慢慢看到好多了。我会告诉你一些事情。
-
$SQL 行上的分号之前应该有另一个 " - 它在上面丢失了,我在大约一个小时前尝试编辑它,但编辑没有放在它的位置 - 我已经再试一次,但这是一个说明应该纠正的地方
-
我不明白你的回答
-
$SQL = "INSERT INTO 'table1' ('ct') VALUE('" .$contenido. "')";... 另外,您是否尝试过print_r($_POST);来查看发送的内容??