輸入待尋字串
  <?php
  require("http://php.wilson.gs");  // 回首頁
  echo "http://php.wilson.gs/bible/function.php : 函式:mysql_connect()";


函式:mysql_connect()


mysql_connect

開啟 MySQL 伺服器連線。

語法: int mysql_connect(string [hostname] [:port], string [username], string [password]);

傳回值: 整數

函式種類: 資料庫功能

內容說明

本函式建立與 MySQL 伺服器的連線。其中所有的參數都可省略。當使用本函式卻不加任何參數時,參數 hostname 的內定值為 localhost、參數 username 的內定值為 PHP 執行行程的擁有者、參數 password 則為空字串 (即沒有密碼)。而參數 hostname 後面可以加冒號與埠號,代表使用那個埠與 MySQL 連接。當然在使用資料庫時,早點使用 mysql_close() 將連線關掉可以節省資源。

使用範例

這是一位未具名網友提供的範例 (18-Feb-1999)
<?php
$dbh 
=  mysql_connect('localhost:3306','mcclain','standard');
mysql_select_db('admreqs');
$query "insert into requests(date, request, email, priority,status) values (NOW(),'$description', '$email', '$priority', 'NEW')";
$res mysql_query($query$dbh);
$query "select max(id) from requests";
$res mysql_query($query$dbh);
$err mysql_error();
if(
$err){
  echo 
"發生錯誤,請通知<a href=mailto:webmaster@my.site>站長</a>";
}
  
$row mysql_fetch_row($res);
  echo 
"未來您使用的號碼為: ".$row[0];
?>

參考

mysql_close()  mysql_pconnect()  


[ 上一頁 /bible/function.php 下一頁 ]



本站置於 NEC BIGLOBE 地球村網際網路  echo "Copyright © 1999-2001, Wilson Peng";  //隱私權保護政策
  mail("wilson@biglobe.net.tw", "Feedback", $message);
  ?>