tybdm tybdm
关注数: 8 粉丝数: 14 发帖数: 148 关注贴吧数: 8
求助,为何我的数据不能写入数据库 为何我的数据不能写入数据库 数据库表的结构 phpMyAdmin SQL Dump -- version 4.6.4 -- http://tieba.baidu.com/mo/q/checkurl?url=https%3A%2F%2Fwww.phpmyadmin.net%2F&urlrefer=5dcd8cde45335ebbb7299ca8ffbea68e -- -- Host: 127.0.0.1 -- Generation Time: 2017-03-11 06:17:36 -- 服务器版本: 5.7.14 -- PHP Version: 5.6.25 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; -- -- Database: `yisu` -- -- -------------------------------------------------------- -- -- 表的结构 `yonghu` -- CREATE TABLE `yonghu` ( `id` int(5) NOT NULL COMMENT '//用户id', `user` varchar(20) NOT NULL COMMENT '//用户名', `pass` varchar(20) NOT NULL COMMENT '//用户密码', `email` varchar(100) NOT NULL COMMENT '//电子邮箱', `QQ` varchar(11) NOT NULL COMMENT '//用户QQ', `mtime` datetime NOT NULL COMMENT '//用户注册时间', `birthday` datetime NOT NULL COMMENT '//生日', `sex` char(2) NOT NULL COMMENT '//用户性别' ) ENGINE=MyISAM DEFAULT CHARSET=utf8; php代码为 session_start(); if(isset($_POST["dosubmit"])){ if(strtolower($_SESSION["code"])==strtolower($_POST["code"])){ //链接数据库 define('_DNS_','mysql:host=localhost;dbname=yisu'); define('_NAME_','root'); define('_PASSWORD_','yisu1234'); $pdo=new PDO(_DNS_,_NAME_,_PASSWORD_) or die('数据库链接失败!'); $pdo->exec("SET NAMES 'utf8'"); $_content=array(); $_content['user']=$_POST['user']; $_content['pass']=md5($_POST['pass']); $_content['email']=$_POST['email']; $_content['qq']=$_POST['qq']; $_content['time']=date('Y-m-d H:i:s'); $_content['chusheng']=$_POST['chusheng']; $_content['sex']=$_POST['sex']; $a = $pdo->prepare("INSERT INTO yonghu (user, pass, email, QQ,mtime,birthday,sex)VALUES (?,?,?,?,?,?,?)"); $a->execute(array($_content['user'],$_content['pass'],$_content['email'],$_content['qq'],$_content['time'],$_content['chusheng'],$_content['sex'])); echo "<script>alert('注册成功!')</script>"; }else{ echo '<script>alert("验证码错误,请重新输入!")</script>'; } } ?>
1 下一页