为什么会注册失败?
问题描述
//连接库$link = new mysqli('localhost', 'root', 'root', 'login');if (!$link) { die("连接失败: " . mysqli_connect_error());}$result = $link -> query("SELECT user FROM log WHERE user = "."'$user'");$rs = $result -> fetch_row();if (!empty($rs)) {echo "<script>alert('用户已存在!');location.href='../login.html';</script>";} else {$link = new mysqli('localhost', 'root', 'root', 'login');$sql="insert into log(user,pwd,sex,age) values('$user','$pwd','$sex','$age')";$rs = mysqli_query($link,$sql);if (!$rs) {echo "<script>alert('注册失败!');location.href='../login.html';</script>";} else {echo "<script>alert('注册成功!返回登录页面');location.href='../index.html';</script>";}}
为什么会注册失败?
数据库也没有写进去数据
问题解答
回答1:打印出sql语句,在mysql工具里面试相关文章:
1. python - 请问用cxfreeze打包的可执行程序能反编译出源码么?2. javascript - 这种上传图片预览怎么做?3. javascript - prismplayer播放器全屏问题4. javascript - vue2.0中router.repalce跟router.push有什么区别,二者的应用场景是会有怎样的区别?5. javascript - js判断一个数组是否重复6. javascript - input输入框触发change事件后,外部元素会被选中7. python - 用__call__ 实现装饰器功能8. javascript - 把字符串日期转换成一般时间格式后,发现小于10的数字不会自动添加0在前面,如下9. python相关问题求解决,有偿10. javascript - 在sublime中如何给.vue文件注释?