1.die()函数:表示向用户输出引号中的内容后,程序终止运行,提示定制的出错信息
ex:
$conn = mysqli_connect("localhost", "root", "","zhym_02") or die("连接数据库服务器失败!".mysqli_error());
2.mysqli_connnect()函数:连接MySQL服务器
ex: $conn = mysqli_connect(“localhost”,”root”,””);
$conn = mysql_select_db($conn, “zhym_01”);
或
$conn = mysqli_connect("localhost", "root", "","zhym_02");
3.mysqli_select_db()函数:选择MySQL数据库
ex:
$select = mysqli_select_db($conn, "zhym_01");
4.mysqli_query()函数:执行SQL语句,设置编码格式
ex:
mysqli_query($conn, "set names gb2312"); //设置编码格式
$result = mysqli_query($conn, "select * from tb_user");
5.mysqli_fetch_array()函数:从结果集中获取一行作为枚举数组
ex: $result = mysqli_fetch_array($arr,MYSQL_ASSOC)
6.mysqli_num_rows()函数:获取查询结果集中的记录数
ex:
while ($row=mysqli_fetch_row($result))
{
printf ("%s (%s)n",$row[0],$row[1]);
}
7.mysqli_free_result()函数:释放内存
ex: mysqli_free_result($result);
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/yangyao_iphone/article/details/47440975