编写一段php以连接到数据库,假定数据库的地址为127.0.0.1:23456
时间: 2023-03-14 17:52:08 浏览: 141
<?php
$host = '127.0.0.1';
$port = 23456;
$user = 'username';
$pass = 'password';
$dbname = 'databasename';// Create connection
$conn = new mysqli($host, $user, $pass, $dbname, $port);
// Check connection
if ($conn->connect_error) {
die('Connection failed: ' . $conn->connect_error);
}
?>
阅读全文