php
连接数据库
header("Content-type:text/html; charset=utf8");
$servername = "localhost";
$username = "root";
$password = "root";
$dbTable = "dvwa";
$conn = mysqli_connect($servername, $username, $password, $dbTable);
if(!$conn)
die("mysql连接失败:".mysqli_connect_error());
echo "mysql连接成功!";
php
查询数据库
$result = mysqli_query($conn, "select * from Student;"); // 获得结果
$data = mysqli_fetch_array($result) // 以数组的方式取出数据
php
实现增删改
$result = mysqli_query($conn, $sql);
$affected_row = mysqli_affected_rows($conn); // 影响的数据条数,整数
if($affected_row) {
echo 'success';
} else {
echo 'error';
}
标签:about,php,affected,echo,DBMA,mysql,mysqli,PHP,conn
From: https://www.cnblogs.com/nerd-/p/17866878.html