這一篇我們來看看PHP和MySQL如何做連接
一、連接資料庫:
在連接資料庫的部分,使用以下的函式:
$變數 = mysql_connect([server名稱],[使用者帳號],[MySQL的密碼]);
或者是
$變數 = mysql_pconnect([server名稱],[使用者帳號],[MySQL的密碼]);
範例:
<?php
$test=mysql_connect("localhost","Lee","nnn");
?>
二、選擇資料庫:
在選擇資料庫的部分,使用以下的函式:
mysql_select_db("資料庫名稱");
範例:
<?php
$test=mysql_connect("localhost","Lee","nnn");
mysql_select_db("audience");
?>
全站熱搜
留言列表