php Mysql


<?php

$conn = mysqli_connect(
    'localhost', /* The host to connect to 连接MySQL地址 */
    'root',   /* The user to connect as 连接MySQL用户名 */
    'root', /* The password to use 连接MySQL密码 */
    'mydatabase');  /* The default database to query 连接数据库名称*/

if (!$conn) {
    printf("Can't connect to MySQL Server. Errorcode: %s ", mysqli_connect_error());
    exit;
}

$sql="insert into student values('zbc','男','itcast0005',23);";



$result = mysqli_query($conn,$sql);

echo $result;


?>

mysql> select * from student;
+-----------+--------+------------+------+
| name      | gender | number     | age  |
+-----------+--------+------------+------+
| 张越      | 男     | itcast0005 |   22 |
| 张越123   | 男     | itcast0005 |   23 |
+-----------+--------+------------+------+
2 rows in set (0.00 sec)

mysql> select * from student;
+-----------+--------+------------+------+
| name      | gender | number     | age  |
+-----------+--------+------------+------+
| 张越      | 男     | itcast0005 |   22 |
| 张越123   | 男     | itcast0005 |   23 |
| zbc       | 男     | itcast0005 |   23 |
+-----------+--------+------------+------+
3 rows in set (0.00 sec)

mysql> 
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。