คำสั่ง connect mysqli ด้วยภาษา PHP

คำสั่ง connect mysql ด้วยภาษา PHP



$host = "localhost";
$username = "root";
$userpassword = "root";
$dbname = "mydatabase";
  
$conn = mysqli_connect($host ,$username ,$userpassword ,$dbname);

if (mysqli_connect_errno())
{
	echo "Database Connect Failed : " . mysqli_connect_error();
}
else
{
	echo "Database Connected.";
}

mysqli_close($conn);



อ้างอิงรูปภาพ https://pixabay.com/photos/code-coding-web-development-944499/