时间:2021-07-01 10:21:17 帮助过:14人阅读
$conn = @mysql_connect("localhost","root","") or die("数据库连接出错!");
mysql_select_db("gb",$conn);
mysql_query("set names 'GBK'");
?>
add.php
代码如下:
include("config.php");
if($_POST['submit']){
//在这里的时候,忘记message里还有个字段lastdate没有写,导致插入数据不成功。找了好久才找出错误。
$sql="insert into message (id,user,title,content,lastdate) values ('','$_POST[user]','$_POST[title]','$_POST[content]',now())";
mysql_query($sql);
echo "成功";
}
?>
view.php
代码如下:
include("config.php");
?>
标题: 用户: |
内容: |
CREATE TABLE `message` (
`id` tinyint(1) NOT NULL auto_increment,
`user` varchar(25) NOT NULL,
`title` varchar(50) NOT NULL,
`content` tinytext NOT NULL,
`lastdate` date NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=gbk AUTO_INCREMENT=1 ;
http://www.bkjia.com/PHPjc/321804.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/321804.htmlTechArticleconfig.php 代码如下:
?php $conn = @mysql_connect("localhost","root","") or die("数据库连接出错!"); mysql_select_db("gb",$conn); mysql_query("set names 'GBK'...