新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
php連接MySQL數(shù)據(jù)庫的實際操作步驟與代碼
以下的文章主要介紹的是php連接MySQL數(shù)據(jù)庫的實際操作步驟以及對php連接MySQL數(shù)據(jù)庫的時機應(yīng)用代碼的描述,下面就是對其相關(guān)內(nèi)容的具體內(nèi)容描述,希望會給你帶來一些幫助在此方面。

PHP操作MySQL
extension=php_MySQL.dll打開
- $servername = "127.0.0.1";
- $username = "root";
- $password = "123456";
- $conn = MySQL_connect($servername, $username, $password);
建立MySQL連接
- if($conn) {
echo "連接MySQL數(shù)據(jù)庫成功";
- }
- //MySQL_select_db("easytoo");
選擇要連接的數(shù)據(jù)庫
或者
- MySQL_query("use easytoo",$conn);
選擇要連接MySQL數(shù)據(jù)庫
- MySQL_query("SET NAMES utf8");
- $rs = MySQL_query("select id from et_category");
查詢獲取一個數(shù)據(jù)集
- MySQL_num_rows($rs);
得到記錄集總數(shù)
- while($row= mysql _fetch_array($rs))
循環(huán)數(shù)據(jù)集
- {
- echo "$row[0]
";- }
- mysql_free_result($rs);
釋放rs
- mysql_close($conn);
關(guān)閉連接
- ?>
以上的相關(guān)內(nèi)容就是對php連接MySQL數(shù)據(jù)庫的介紹,望你能有所收獲。
【編輯推薦】
- MySQL數(shù)據(jù)庫內(nèi)存調(diào)優(yōu)實操
- Python編程語言操作MySQL數(shù)據(jù)庫實戰(zhàn)演習(xí)
- apache+php+MySQL服務(wù)器搭建,并不難
- MySQL索引和查詢優(yōu)化的實際操作
- MySQL語句優(yōu)化的原則簡述
網(wǎng)站題目:php連接MySQL數(shù)據(jù)庫的實際操作步驟與代碼
文章來源:http://m.fisionsoft.com.cn/article/djjipes.html


咨詢
建站咨詢
