交付后不能向数据库插入数据

WBOY
Release: 2016-06-13 13:09:05
Original
765 people have browsed it

提交后不能向数据库插入数据
conn.php

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><?php $conn = @ mysql_connect("localhost", "root", "root") or die("数据库链接错误");
   mysql_select_db("bbs", $conn);
   mysql_query("set names 'GBK'"); //使用GBK中文编码;

?>
Copy after login


add.php
PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><?php include("conn.php");

   if($_POST['submit']){
   
     $sql="insert into message (id,user,title,content,lastdate) 
     values ('','$_POST[user]','$_POST[title]','$_POST[content]',now())";
   
   mysql_query($sql);
   echo "发表成功";
   }

?>

Copy after login
用户:
标题:
内容:




点击发表留言后在数据库找到记录,是代码有问题吗?

------解决方案--------------------
mysql_query($sql) or die(mysql_error()); //这样报错了没有
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template