PHP7.27: connect mysql 5.7 using new mysqli
<!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的更多相关文章
- PHP7.27: connect mysql 5.7 using new mysqli_connect
<!doctype html> <html> <head> <meta name="viewport" content="wid ...
- discuz对PHP7不支持mysql的兼容性处理
PHP7 废除了 ”mysql.dll” ,推荐使用 mysqli 或者 pdo_mysql,discuz对原生mysql函数做了如下处理,通过mysqli代替原mysql函数 http://blog ...
- linux非root用户安装5.7.27版本mysql
先下安装包,到mysql官网https://dev.mysql.com/downloads/mysql/选好安装包版本.操作系统类型(默认是最新版本,点击右边链接Looking for previou ...
- 虚拟机中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 ...
- 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 ...
- 如何在PHP7中安装mysql的扩展
相对与PHP5,PHP7的最大变化之一是移除了mysql扩展,推荐使用mysqli或者pdo_mysql,实际上在PHP5.5开始,PHP就着手开始准备弃用mysql扩展,如果你使用mysql扩展,可 ...
- (二)阿里云ECS Linux服务器外网无法连接MySQL解决方法(报错2003- Can't connect MySQL Server on 'x.x.x.x'(10038))(自己亲身遇到的问题是防火墙的问题已经解决)
我的服务器买的是阿里云ECS linux系统.为了更好的操作数据库,我希望可以用navicat for mysql管理我的数据库. 当我按照正常的模式去链接mysql的时候, 报错提示: - Can' ...
- 从PHP5到PHP7的注意事项——PHP7全面删除Mysql扩展支持
PHP删除了一些函数,其中是吓人的是两个: 1. ereg_* 系列的正则函数 2. mysql_* 系列的数据库连接函数 PHP7全面删除Mysql扩展支持,原本的mysql_*系列函数将在mysq ...
- 如何在PHP7中扩展mysql,先安装php7.2。后安装mysql
相对与PHP5,PHP7的最大变化之一是移除了mysql扩展,推荐使用mysqli或者pdo_mysql,实际上在PHP5.5开始,PHP就着手开始准备弃用mysql扩展,如果你使用mysql扩展,可 ...
随机推荐
- 【接口时序】3、UART串口收发的原理与Verilog实现
一.软件平台与硬件平台 软件平台: 1.操作系统:Windows-8.1 2.开发套件:ISE14.7 3.仿真工具:ModelSim-10.4-SE 硬件平台: 1.FPGA型号:XC6SLX45- ...
- 小游戏——金庸奇侠传(JAVA,对面向对象的进一步了解)
金庸群侠传 游戏运行界面: 游戏实现源码: package game.logic; //人类 public class Person { public String name; //名字 Pers ...
- B - Red and Black 问题思考
红黑地板问题 There is a rectangular room, covered with square tiles. Each tile is colored either red or bl ...
- Hbase shell基本操作
1.启动cd <hbase_home>/bin$ ./start-hbase.sh 2.启动hbase shell # find hadoop-hbase dfs fileshadoop ...
- C#开源项目大全
C#开源项目大全 商业协作和项目管理平台-TeamLab 网络视频会议软件-VMukti 驰骋工作流程引擎-ccflow [免费]正则表达式测试工具-Regex-Tester Windows-Ph ...
- 211. Orchard学习 二 2、ManualResetEvent 与 AutoResetEvent
一.Orchard里异步请求处理线程队列的控制 Orchard的Orchard.WarmupStarter模块,为HttpApplication.BeginRequest时间附加了一个异步处理事件:B ...
- 安装scrapy框架出错的解决
要安装scrapy 一般会出现 以下错误(要先安装twisted) 今天通过pip安装twisted遇到了“error: Microsoft Visual C++ 14.0 is required”错 ...
- glide使用
glide在github地址:https://github.com/bumptech/glide 1.添加依赖(最好看官网,因为有时候添加依赖的会有轻微改动,版本也会一直更新) repositorie ...
- Nginx 的两种认证方式
简介: 今天来研究一下 Nginx 的两种认证方式. 1.auth_basic 本机认证 2.ngx_http_auth_request_module 第三方认证 一.安装 Nginx shell & ...
- openssl签署和自签署证书的多种实现方式
openssl系列文章:http://www.cnblogs.com/f-ck-need-u/p/7048359.html 1.采用自定义配置文件的实现方法 1.1 自建CA 自建CA的机制:1.生成 ...