php mysql操作mysql_connect串連資料庫

來源:互聯網
上載者:User
php操作資料庫首先必須串連到指定的資料庫,串連資料庫可以使用PHP mysql_connect函數,本文章向大家介紹mysql_connect函數的使用方法和執行個體,需要的朋友可以參考一下

mysql_connect介紹

php mysql_connect用於串連mysql伺服器,該函數有多個參數,但我們一般只需要瞭解以下三個參數即可:

mysql_connect(server,user,pwd)

參數介紹:

  • server -- mysql伺服器位址

  • user -- 伺服器使用者名稱

  • pwd -- 伺服器登入密碼

如果串連成功,則返回一個 MySQL 串連標識,如果串連失敗則返回 FALSE。

mysql_connect執行個體

 <?php $host="mysql153.secureserver.net"; $uname="root"; $pass="password";  $connection= mysql_connect ($host, $uname, $pass); if (! $connection) {  die ("mysql伺服器串連失敗"); } else {  echo "恭喜你!mysql伺服器串連成功"; } ?>

以上就是本文的全部內容,希望對大家的學習有所協助。


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.