Your code is not managed correctly. You’ll have to assign the connections to certain variables. Also, as @akhilkumar332 suggested, it’s better to use
Use this sample code:
$host = 'xxx';
$username = 'xxx';
$password = 'xxx';
$database = 'xxx';
$connection = mysqli_connect($host, $username, $password, $database); // connect and select the database at the same time;
if(!$connection) // prints connection error if any
$query = mysqli_query($connection, "SELECT * FROM xxx"); // the query to execute; result will be assigned as object to $query
if(!$query) // prints query error if any
mysqli_close($connection); // disconnects $connection from MySQL server
why my second die() not worked ?
die() kills the execution of the script. If you have passed one
die() it’s natural that the next ones will not be passed as the execution of the script will be stopped.