PHP7.27: connect mysql 5.7 using new mysqli_connect




	

my sql

 



 '127.0.0.1:3306', 
    'db'      => 'sakila', 
    'db_user' => 'root', 
    'db_pwd'  => '88888', 
    );	
$link = mysqli_connect($mysql_conf['host'],$mysql_conf['db_user'], $mysql_conf['db_pwd'],$mysql_conf['db']);
$link->query("set names 'utf8';");//编码转化
/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

$query = "select * from city ORDER BY city_id;";
// 获取表格字段属性
if ($result = mysqli_query($link, $query)) {

    /* Get field information for all fields */
    while ($finfo = mysqli_fetch_field($result)) {

        printf("Name:     %s\n", $finfo->name);
        printf("Table:    %s\n", $finfo->table);
        printf("max. Len: %d\n", $finfo->max_length);
        printf("Flags:    %d\n", $finfo->flags);
        printf("Type:     %d\n\n", $finfo->type);
		echo("
"); } mysqli_free_result($result); } // echo(""); // 显示字段名 if ($result = mysqli_query($link, $query)) { while($field=mysqli_fetch_field($result)) { echo(""); } mysqli_free_result($result); } echo(""); // 显示行数据 if ($resultrow = mysqli_query($link, $query)) { while($row=mysqli_fetch_row($resultrow)) { echo(""); for($i=0;$i".$row[$i].""); } echo(""); } } echo("
".$field->name."
"); /* close connection */ mysqli_close($link); ?>

 

你可能感兴趣的:(PHP)