<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<title>my sql</title>
<meta name="keywords" content="geovindu">
<meta name="description" content="涂聚文">
</head>
<body>
<?php
// php 7.27 mysql 5.7
/*
character_set_client utf8
character_set_connection utf8
character_set_database utf8 -- 安装mysql时要设置的,所要考虑的
character_set_filesystem binary
character_set_results utf8
character_set_server utf8
character_set_system utf8
*/
$mysql_conf = array(
'host' => '127.0.0.1:3306',
'db' => 'sakila',
'db_user' => 'root',
'db_pwd' => '888888',
); $mysqli = @new mysqli($mysql_conf['host'], $mysql_conf['db_user'], $mysql_conf['db_pwd']);
if ($mysqli->connect_errno) {
die("could not connect to the database:\n" . $mysqli->connect_error);//诊断连接错误
}
$mysqli->query("set names 'utf8';");//编码转化
$select_db = $mysqli->select_db($mysql_conf['db']);
if (!$select_db) {
die("could not connect to the db:\n" . $mysqli->error);
}
$sql = "select city from city where city_id = 601;";
$res = $mysqli->query($sql); //$result = mysql_query($sql) or die($sql."<br/><br/>".mysql_error());
//$password = mysql_result($result, 0);
// echo $password;
if (!$res) {
die("sql error:\n" . $mysqli->error);
}
while ($row = $res->fetch_assoc()) {
var_dump($row);
} // 显示字段名称
$sql = "select * from city where city_id = 601;";
$res = $mysqli->query($sql);
while($field=$res->fetch_field())
echo("<br/>".$field->name); //显示某行
$sql = "select * from city where city_id = 601;";
$res = $mysqli->query($sql);
while($rowd=$res->fetch_row())
for($i=0;$i<$res->field_count;$i++)
echo("<br/>".$rowd[$i]); $res->free();
$mysqli->close(); ?> </body>
</html>

  

PHP7.27: connect mysql 5.7 using new mysqli的更多相关文章

  1. PHP7.27: connect mysql 5.7 using new mysqli_connect

    <!doctype html> <html> <head> <meta name="viewport" content="wid ...

  2. discuz对PHP7不支持mysql的兼容性处理

    PHP7 废除了 ”mysql.dll” ,推荐使用 mysqli 或者 pdo_mysql,discuz对原生mysql函数做了如下处理,通过mysqli代替原mysql函数 http://blog ...

  3. linux非root用户安装5.7.27版本mysql

    先下安装包,到mysql官网https://dev.mysql.com/downloads/mysql/选好安装包版本.操作系统类型(默认是最新版本,点击右边链接Looking for previou ...

  4. 虚拟机中MySQL连接问题:Lost connection to MySQL server at 'reading initial communication packet, system error: 0 以及 host is not allowed to connect mysql

    环境:在VirtualBox中安装了Ubuntu虚拟机,网络使用了NAT模式,开启了端口转发. 局域网内其他计算机访问虚拟机中的MySQL Server出现两个问题: Lost connection ...

  5. Howto: Connect MySQL server using C program API under Linux or UNIX

    From my mailbag: How do I write a C program to connect MySQL database server? MySQL database does su ...

  6. 如何在PHP7中安装mysql的扩展

    相对与PHP5,PHP7的最大变化之一是移除了mysql扩展,推荐使用mysqli或者pdo_mysql,实际上在PHP5.5开始,PHP就着手开始准备弃用mysql扩展,如果你使用mysql扩展,可 ...

  7. (二)阿里云ECS Linux服务器外网无法连接MySQL解决方法(报错2003- Can't connect MySQL Server on 'x.x.x.x'(10038))(自己亲身遇到的问题是防火墙的问题已经解决)

    我的服务器买的是阿里云ECS linux系统.为了更好的操作数据库,我希望可以用navicat for mysql管理我的数据库. 当我按照正常的模式去链接mysql的时候, 报错提示: - Can' ...

  8. 从PHP5到PHP7的注意事项——PHP7全面删除Mysql扩展支持

    PHP删除了一些函数,其中是吓人的是两个: 1. ereg_* 系列的正则函数 2. mysql_* 系列的数据库连接函数 PHP7全面删除Mysql扩展支持,原本的mysql_*系列函数将在mysq ...

  9. 如何在PHP7中扩展mysql,先安装php7.2。后安装mysql

    相对与PHP5,PHP7的最大变化之一是移除了mysql扩展,推荐使用mysqli或者pdo_mysql,实际上在PHP5.5开始,PHP就着手开始准备弃用mysql扩展,如果你使用mysql扩展,可 ...

随机推荐

  1. 牛客JS编程大题(一)

    1.找出元素 item 在给定数组 arr 中的位置 function indexOf(arr,item){ return arr.indexOf(item);} 2.计算给定数组 arr 中所有元素 ...

  2. 彻底理解Java中的基本数据类型转换(自动、强制、提升)

    说基本数据类型转换之前,先了解下 Java 中的 8 种基本数据类型,以及它们的占内存的容量大小和表示的范围,如下图所示. 重新温故了下原始数据类型,现在来解释下它们之间的转换关系. 自动类型转换 自 ...

  3. javascript编程中this解析

    一.为什么要使用this? this 提供了一种更优雅的方式来隐式"传递"一个对象引用,因此可以将 API 设计得更加简洁并且易于复用.随着你的使用模式越来越复杂,显式传递上下文对 ...

  4. PCA历程详细python代码(原创)

    #PCA主成分分析,原文为文末的链接,代码为自己亲自手码 def cov_out1(dx,dy): #第一步:求解x,y各自的均值 mean_x=0 mean_y=0 for i in range(l ...

  5. maven-assembly-plugin的使用

    maven-assembly-plugin使用描述(拷自 maven-assembly-plugin 主页) The Assembly Plugin for Maven is primarily in ...

  6. 小程序flex容器

    flex:默认:水平方向是主轴,垂直方向是交叉轴,分布在第四象限,项目时在主轴方向上排列, 排满之后在交叉轴方向上换行: 1.设置容器的属性 display:flex 通过设置坐标轴来设置项目的排列方 ...

  7. 从零开始学 Web 之 ES6(五)ES6基础语法三

    大家好,这里是「 从零开始学 Web 系列教程 」,并在下列地址同步更新...... github:https://github.com/Daotin/Web 微信公众号:Web前端之巅 博客园:ht ...

  8. Spring Cloud Ribbon——客户端负载均衡

    一.负载均衡负载均衡(Load Balance): 建立在现有网络结构之上,它提供了一种廉价有效透明的方法扩展网络设备和服务器的带宽.增加吞吐量.加强网络数据处理能力.提高网络的灵活性和可用性.其意思 ...

  9. flask 压缩json

    这样返回的json会被压缩

  10. Java线程中的join使用实例

    JDK中解释为 Waits for this thread to die. 等待本线程结束后,下一个线程才可以运行. 实例要求: 现在有T1.T2.T3三个线程,你怎样保证T2在T1执行完后执行,T3 ...