这个代码有问题吗? 为什么老是创建不了数据库表?
$con = mysql_connect("localhost","root","") or die("连接错误");
$ab = mysql_select_db("my_db", $con);
if($ab){
echo "成功了";
}
$sql = "CREATE TABLE `test` (
`id` int(10) NOT NULL auto_increment,
`uid` varchar(10) NOT NULL default '0',
`regdate` date NOT NULL,
`remark` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=gbk AUTO_INCREMENT=1 ;
INSERT INTO `test` (`id`, `uid`, `regdate`, `remark`) VALUES
(1, '张三', '2008-07-02', '学生'),
(2, '李四', '2008-07-03', '学生'),
(3, '王五', '2008-07-02', '工人'),
(4, '赵六', '2008-07-01', '学生');
";
$abc = mysql_query($sql,$con);
if($abc){
echo "建立成功";
}else {
echo "失败了";
}
?>
<br /> $con = mysql_connect("localhost","root","") or die("连接错误");<br /> $ab = mysql_select_db("my_db", $con);<br /> if($ab){<br /> echo "成功了";<br /> }<br /> $sql = "CREATE TABLE `test` (<br /> `id` int(10) NOT NULL auto_increment,<br /> `uid` varchar(10) NOT NULL default '0',<br /> `regdate` date NOT NULL,<br /> `remark` text,<br /> PRIMARY KEY (`id`)<br /> ) ENGINE=InnoDB DEFAULT CHARSET=gbk AUTO_INCREMENT=1 ;<br /> $abc = mysql_query($sql,$con);<br /> if($abc){<br /> echo "建立成功";<br /> }else {<br /> echo "失败了";<br /> }<br /> $sql1="INSERT INTO `test` (`id`, `uid`, `regdate`, `remark`) VALUES<br /> (1, '张三', '2008-07-02', '学生')"<br /> $result=mysql_query($sql1);<br /> if($result){<br /> echo "插入数据成功";<br /> }<br /> <br /> <br />