留言板连接数据库的问题
填完留言板 数据库中没有提交的数据怎么回事??
文件conn.php:
$conn = @ mysql_connect("localhost", "root", "") or die("数据库链接错误");
mysql_select_db("bbs", $conn);
mysql_query("set names 'GBK'");
?>
文件add.php:
include("conn.php");
if($_POST[submit]){
$sql="insert into ted (id,user,title,content,lastdate) values ('','$_POST[user]'),'$_POST[title]','$_POST[content]'," .
"now()";
mysql_query($sql);
echo "发表成功!";
}
?>
------解决方案--------------------mysql_query($sql) or die(mysql_error());
报什么错
------解决方案--------------------起码SQL中的括号就有问题
------解决方案-------------------- $sql="insert into ted (id,user,title,content,lastdate) values ('','$_POST[user]'),'$_POST[title]','$_POST[content]'," .
"now()";
里面有一个),要把它写在后面
$sql="insert into ted (id,user,title,content,lastdate) values ('','$_POST[user]','$_POST[title]','$_POST[content]'," .
"now()");
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn