找到php_mysqli.dll,取消前面的注释
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
extension=php_mbstring.dll
;extension=php_exif.dll ; Must be after mbstring as it depends on it
extension=php_mysql.dll
extension=php_mysqli.dll
使用phpinfo();查看当前php支持什么扩展库。
create table user1( id int primary key auto_increment, name varchar(32) not null, password varchar(64) not null, email varchar(128) not null, age tinyint unsigned not null )
insert into user1 (name ,password ,email,age) values('zs',md5('123456'),'[email protected]',12); insert into user1 (name ,password ,email,age) values('小明',md5('123456'),'[email protected]',13); insert into user1 (name ,password ,email,age) values('小花',md5('123456'),'[email protected]',14); insert into user1 (name ,password ,email,age) values('ls',md5('123456'),'[email protected]',15);
php
header("charset=utf-8");
//mysqli操作mysql数据库(面向对象风格)
//1获取数据库连接
$mysqli = new mysqli("localhost", "root", "xuex", "php01");
//判断是否成功
if($mysqli->connect_errno){
die("����ʧ��".$mysqli->connect_errno);
}
//设置连接的编码
mysqli_query($mysqli,"set names utf8");
//2定义sql语句
$sql = "select * from user1";
//获得结果
$res = $mysqli->query($sql);
//3、提取一行数据
while ($row=$res->fetch_row()){
foreach ($row as $key=>$val){
echo "--$val";
}
echo "
";
}
//4、释放资源
//释放内存
$res->free();
//关闭连接
$mysqli->close();
页面结果
--1--zs--e10adc3949ba59abbe56e057f20f883e--zs@qq.com--12 --2--小明--e10adc3949ba59abbe56e057f20f883e--xm@qq.com--13 --3--小花--e10adc3949ba59abbe56e057f20f883e--xh@qq.com--14 --4--ls--e10adc3949ba59abbe56e057f20f883e--ls@qq.com--15