PHP Connect to MySQL Database
This PHP script connects to a MySQL database.
<?php /** * MySQL Database Connection * * When you need to connect to your database, * simply put in the host, username, password, * and database info below,then use a require * or include command in your code prior to * executing any MySQL commands. * * @author PHP Simple * @website http://phpsimple.com * @date August 2021 */ $dc_host = "localhost"; // Host Name $dc_user = "admin"; // Username $dc_pass = "password"; // Password $dc_db = "database"; // Database Name // Create connection $dc_conn = new mysqli($dc_host, $dc_user, $dc_pass, $dc_db); // Check connection if ($dc_conn->connect_error) { die("Connection failed: " . $dc_conn->connect_error); } ?>