include(conn/conn.php);
if($_POST[submit]){
$code = $_POST[‘code’];
$note = $_POST[‘note’];
$routeway = $_POST[‘routeway’];
$operator = $_POST[‘operator’];
if($code!= “” || $note != “” || $routeway != “” || $operator !=””){
$sql =”INSERT INTO code_group (groupNumber,groupCode,groupNote,groupRouteway,groupOperator) VALUES(”,’$code’,’$note’,’$routeway’,’$operator’)”;
if(mysql_query($sql)){
echo”<script>alert(‘插入成功’);</script>”;
}else{
echo”<script>alert(‘插入失败’);</script>”;
}
}else{
echo”<script>alert(‘您输入的内容为空’);</script>”;
}
}
?>
这是库设置
CREATE TABLE `code_group` (
`groupNumber` smallint(6) NOT NULL,
`groupCode` char(8) NOT NULL,
`groupNote` varchar(100) NOT NULL,
`groupRouteway` char(15) NOT NULL,
`groupOperator` char(4) NOT NULL,
PRIMARY KEY (`groupNumber`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
PHP程序能运行没问题,连接数据库也正常,就是插不进去数据,不知道是怎么原因。
回复讨论(解决方案)
groupNumber 主键 插入空值
下次碰到类似的 先跑一遍自己的sql语句
echo mysql_error();
就能看到错误的原因
groupNumber 主键 插入空值
下次碰到类似的 先跑一遍自己的sql语句
给它赋值也没用,数据库报错Access denied for user ”@’localhost’ (using password: NO),可是连接数据库的密码没有错的 啊。
echo mysql_error();
就能看到错误的原因
报错Access denied for user ”@’localhost’ (using password: NO)
可是连接数据库的密码是正确的,不知道怎么解决这个问题。
Access denied for user ”@’localhost’ ( using password: NO)
你连接时并没有口令,怎么说是“ 可是连接数据库的密码没有错的 啊”6来源gaodaimacom搞#^代%!码网搞gaodaima代码
Access denied for user ”@’localhost’ ( using password: NO)
你连接时并没有口令,怎么说是“ 可是连接数据库的密码没有错的 啊”
百度都说是用户名密码不匹配,参照网上的方法 修改密码,重启mysql这些方法都试过了,还是不行,版主能说一下怎么解决这个问题么。连接数据库查询没有问题,就插入出问题了。
谢谢各位,解决问题了。
问题出在include包含文件,include (conn/conn.php);include 与(conn/conn.php)之间加上空格就解决了。