常用命令整理
创建数据库
CREATE DATABASE name;
USE name;
创建表
CREATE TABLE name (
username varchar(16) not null primary key,
password char(40) not null,
email varchar(100) not null
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
2.插入数据库中文显示乱码解决
1 function db_connect(){ 2 @$db = new mysqli('localhost','root','','bookmarks'); 3 if ($db->connect_errno) { 4 echo "Can't connect database."; 5 exit(); 6 } 7 //设置字符集 8 $db->query("set names utf8"); 9 return $db; 10 }