Home  >  Article  >  Backend Development  >  添加数据后数据库里什么都没有,该怎么解决

添加数据后数据库里什么都没有,该怎么解决

WBOY
WBOYOriginal
2016-06-13 10:08:191385browse

添加数据后数据库里什么都没有
include("conn.php");
 if(isset($_POST['submit'])&&$_POST['submit'])  
{
echo $sql="insert into message (id,user,title,content,lastdata)".
"values('','$_POST[user]','$_POST[title]','$_POST[content]',now())";
mysql_query($sql);
echo "发表成功";
}
?>


用户:

标题:

内容:




------解决方案--------------------
mysql_query($sql) or die(mysql_error());
------解决方案--------------------
不管mysql_query()是否真的成功,都会echo "发表成功"
------解决方案--------------------
把错误打开吧,这样可以根据错误提示做判断,这么看 代码似乎没有问题。但不代表include 部分是正常的
------解决方案--------------------
用手工操作一下sql 语句添加内容试一下。再说。
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