当前位置:Gxlcms > PHP教程 > 留言板连接数据库的有关问题

留言板连接数据库的有关问题

时间:2021-07-01 10:21:17 帮助过:6人阅读

留言板连接数据库的问题
填完留言板 数据库中没有提交的数据怎么回事??


文件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()");

人气教程排行