close

The example for connecting to mysql

<?php

$mysql_ip = 'localhost';

$mysql_user = 'userName';

$mysql_password = 'userPassword';

$link mysql_connect($mysql_ip, $mysql_user,$mysql_password);

if (!$link

{

    die('Could not connect: ' mysql_error());

}

echo 'Connected successfully';

mysql_close($link);

?>


1. $link是一個以resource為type的variable , resource type是php中的特別型態 , 

   是一種專門對外部資源進行存取的型態.

2. die() , 是exit() 函數的別名 , 會輸出一條訊息 , 然後退出php script.

3. mysql_error() , 會return 在對sql進行操作時所產生的錯誤訊息.



arrow
arrow
    文章標籤
    php mysql connection
    全站熱搜

    JerryCheng 發表在 痞客邦 留言(0) 人氣()