php 入門教程:php 與mysql資料庫連接

來源:互聯網
上載者:User

php與mysql資料庫是天生的一對,黃金搭檔的,所以學php的朋友可以說沒有人不會用php與mysql串連的,只是有此新手不會,這能理解,但日後你一定會的,下面我們就來看看php與mysql是如何串連吧,以及文法是怎麼寫的.

mysql_connect(servername,username,password);
好了我們來講講servername,username,password這三個參數吧.
servername:是mysql資料庫
username:mysql資料庫名.
password:串連資料庫的密碼,好了下面我們來看個簡單的例子吧.
<?php$con = mysql_connect("localhost","111cn","123456") or die('資料庫連接失敗');
?>
簡單吧,就這條就行了,這時會有朋友問那如果關閉資料庫連接呢.
 
<?
mysql_close();
?>
這就是關閉哦.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.