phpstudy資料庫建立好之後,
預設使用者名稱:root
##預設密碼:root##主機名稱:localhost
連接埠:3306
demo:<?php
$hostName = "localhost";
$usrName = "root";
$passWord = "root";
$port = "3306";
$dbname = "flyingman";
$content = mysqli_connect($hostName,$usrName,$passWord,$dbname,$port);
mysqli_set_charset($content,'utf-8');
if(!$content){
die("connect failed!:".mysqli_connect_error());
}else{
echo "connect success!";
}
mysqli_close($content);
header("content-type:text/html;charset=utf-8");
推薦教學:
以上是phpstudy連接資料庫程式碼的詳細內容。更多資訊請關注PHP中文網其他相關文章!