国产精品黄页网在线观看,欧美日韩国产综合新一区,国产欧美高清精品一区2,久久国产乱子伦免电影

PHP如何使用mysql_connect鏈接MYSQL數(shù)據(jù)庫

程序猿 2021-03-17 20:28:35 2728瀏覽 加載中

php基本的鏈接mysql數(shù)據(jù)庫在函數(shù)為

$c = mysql_connect("localhost","root","password");

連上數(shù)據(jù)庫后,選擇數(shù)據(jù)庫

$db = mysql_select_db('you_db'); //數(shù)據(jù)庫的名稱

查詢數(shù)據(jù)庫,及打印數(shù)據(jù)

$sql = "select * from you_table ";
$res = mysql_query($sql);
if (!$res) {    
    die("could get the res:\n" . mysql_error());
}
while ($row = mysql_fetch_assoc($res)) {    
    print_r($row);
}

關(guān)閉打開的數(shù)據(jù)庫

mysql_close($con);


標(biāo)簽: php mysql
最后修改:2025-10-29 21:53:28

非特殊說明,本博所有文章均為博主原創(chuàng)。