register.php 注册
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title></head> <body> <form action="registerProc.php" method="post"> <table align="center"> <tr> <td width="80">用户名:</td> <td width="180"><input type="text" name="username" id="username"></td> <td id="mes_username"></td> </tr> <tr> <td>密码:</td> <td><input type="password" name="password" id="password"></td> <td id="mes_password"></td> </tr> <tr> <td>确认密码:</td> <td><input type="password" name="password2" id="password2"></td> <td id="mes_password2"></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" value="注册"> <input type="reset" value="重填"></td> <td></td> </tr> </table> </form> </body></html>
registerProc.php Post处理代码
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title></head> <body> <?php require_once 'db.php'; $username = $_POST['username']; $password = $_POST['password']; $password2 = $_POST['password2']; $registdate = date("Y-m-d H:i:s"); $sql = "INSERT INTO users (USERNAME,PASSWORD,REGISTDATE) values (?,?,?)"; $sth = $conn->prepare($sql); $sth->execute(array($username,$password,$registdate)); if($sth->rowCount()) { echo "insert success"; } else { echo "insert error"; } $conn = null; ?> 注册成功,请<a href="login.php">登录</a>或继续<a href="register.php">注册</a> </body></html>
db.php 连接数据库代码
<?php $url = 'localhost'; $dbname = 'bbs'; $dsn = "mysql:host=$url;dbname=$dbname"; $dbusername = 'root'; $dbpasswd = 'root'; try{ $conn = new PDO($dsn, $dbusername, $dbpasswd); $conn->query("set names utf8"); }catch(PDOException $e){ die("mysql connected error: ".$e->getMessage()); }?>
是PDO写错了吗?我找了好久都没发现在哪出错。我用的数据库是MySQL server 5.6版本的,PHP5.3
回复讨论(解决方案)
print_r($sth->errorInfo());
谢谢!!@xuzuning

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于架构原理的相关内容,MySQL Server架构自顶向下大致可以分网络连接层、服务层、存储引擎层和系统文件层,下面一起来看一下,希望对大家有帮助。

在mysql中,可以利用char()和REPLACE()函数来替换换行符;REPLACE()函数可以用新字符串替换列中的换行符,而换行符可使用“char(13)”来表示,语法为“replace(字段名,char(13),'新字符串') ”。

mysql的msi与zip版本的区别:1、zip包含的安装程序是一种主动安装,而msi包含的是被installer所用的安装文件以提交请求的方式安装;2、zip是一种数据压缩和文档存储的文件格式,msi是微软格式的安装包。

方法:1、利用right函数,语法为“update 表名 set 指定字段 = right(指定字段, length(指定字段)-1)...”;2、利用substring函数,语法为“select substring(指定字段,2)..”。

转换方法:1、利用cast函数,语法“select * from 表名 order by cast(字段名 as SIGNED)”;2、利用“select * from 表名 order by CONVERT(字段名,SIGNED)”语句。

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于MySQL复制技术的相关问题,包括了异步复制、半同步复制等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了mysql高级篇的一些问题,包括了索引是什么、索引底层实现等等问题,下面一起来看一下,希望对大家有帮助。

在mysql中,可以利用REGEXP运算符判断数据是否是数字类型,语法为“String REGEXP '[^0-9.]'”;该运算符是正则表达式的缩写,若数据字符中含有数字时,返回的结果是true,反之返回的结果是false。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

Dreamweaver CS6
視覺化網頁開發工具

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

PhpStorm Mac 版本
最新(2018.2.1 )專業的PHP整合開發工具