Warning : mysqli_select_db() expects parameter 1 to be mysqli, string given in C:\xampp\htdocs\elegance\storescripts\connect.php on line 18
Notice : Undefined variable: dbname in C:\xampp\htdocs\elegance\storescripts\connect.php on line 20
Warning : mysqli_error() expects exactly 1 parameter, 0 given in C:\xampp\htdocs\elegance\storescripts\connect.php on line 20
Failed to connect to database
please i need help with this. i am new to php. below is my code
<?php
//Step 1; create a database connection
require_once('constant.php');
$con = mysqli_connect(HOST, USER, PASSWORD);
// check if connection is successful
if(!$con){
die("Database connection failed" . mysqli_error());
}
?>
<?php
//Step 2: connect to a database
$db = mysqli_select_db(DATABASE, $con);
if(!$db){
die("Failed to connect to database {$dbname}" . mysqli_error());
}