«

php连接数据库?

emer 发布于 2017-10-11 21:25   2329 次阅读     


<?php
$link = mysqli_connect(
    'localhost', 
    'root',     
    'root', 
    'lininn'); 
mysqli_set_charset($link, "utf8");
if (!$link) {
    printf("Can't connect to MySQL Server. Errorcode: %s ", mysqli_connect_error());
    exit;
}else

    $sql = "insert into user1(name1,tit) values('dd44','rrrr')";
$result = mysqli_query($link,$sql); 
// while($row = mysqli_fetch_row($result)){ 
// echo $row[0]; 
// } 

mysqli_close($link);
?>