PHP 表单 无法向 MYSQL 写入数据(急)
conn.php<?php$conn=@mysql_connect("localhost","root","")ordie("数据连接失败");mysql_select_...
conn.php <?php $conn = @ mysql_connect("localhost","root","") or die("数据连接失败"); mysql_select_db("myapp",$conn); mysql_query("set names 'GBK' ");//使用GBK中文编码 ?> home.php <form action="index.php" method="post"> <div>Email:<input type="text" name="mail" maxlength="25"></div> <div>User:<input type="text" name="name" maxlength="10"></div> <div><textarea name="content" rows="6" cols="70"></textarea></div> <div><input type="submit" value="sign guesbook" name="submit"></div> </form> index.php <?php include("home.php"); include("conn.php"); $mail=$_POST['mail']; $name=$_POST['name']; $content=$_POST['content']; if($_POST['submit']){ $sql="insert into content (id,lastdate,mail,name,content) values('',now(),'$mail','$name','$content')"; mysql_query($sql); } ?> 提交表单后 无法在数据库中找到信息,
展开
展开全部
我知道了
原:
$sql="insert
into
content
(id,lastdate,mail,name,content)
values('',now(),'$mail','$name','$content')";
改成:
$sql="insert
into
content
(id,lastdate,mail,name,content)
values(1,now(),'$mail','$name','$content')";
我看你数据库结构id非null数字,给它''肯定不对了
原:
$sql="insert
into
content
(id,lastdate,mail,name,content)
values('',now(),'$mail','$name','$content')";
改成:
$sql="insert
into
content
(id,lastdate,mail,name,content)
values(1,now(),'$mail','$name','$content')";
我看你数据库结构id非null数字,给它''肯定不对了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询