php mysql開發 資料庫連線

2021-06-16 10:07:22 字數 532 閱讀 8440

php為我們提供了兩個擴充套件方便的運算元據庫。乙個是mysql擴充套件,乙個是mysqli擴充套件。

<?php

mysql_connect("localhost","root","root");//建立乙個資料庫連線

mysql_select_db("guestbook");//選擇乙個資料庫

$result = mysql_query("select *from info");//對資料庫執行一條sql語句,返回乙個資源型別

while($row = mysql_fetch_array($result,mysql_assoc))

?>

返回結果:

array( [id] => 1 [name] => root [content] => zhang? [content_time] => 2012-12-12)

array( [id] => 2 [name] => admin [content] => admin? [content_time] => 2012-12-10)

PHP Mysql資料庫連線

1,date default timezone set prc 獲取北京時區 header content type text html charset utf 8 編碼 define db host localhost 資料庫位址,一般為localhost define db user root ...

PHP MySQL 連線資料庫

免費的 mysql 資料庫通常是通過 php 來使用的。在您能夠訪問並處理資料庫中的資料之前,您必須建立到達資料庫的連線。在 php 中,這個任務通過 mysql connect 函式完成。mysql connect servername,username,password 引數 描述servern...

PHP MySQL 連線資料庫

免費的 mysql 資料庫通常是通過 php 來使用的。在您能夠訪問並處理資料庫中的資料之前,您必須建立到達資料庫的連線。在 php 中,這個任務通過 mysql connect 函式完成。mysql connect servername,username,password 引數 描述servern...