This is for PHP 7 to contact mysql.
I want to query the database called "database1" and for it to print the content of this db in the web browser.
<?php
function check_password($username, $password) {
// Create connection
$db = new mysqli('localhost','<DB-USERNAME>','<USER-PASSWORD>','<DATABASENAME>');
// Check for errors
if($db->connect_errno){
echo $db->connect_error;
}
$query = 'SELECT * FROM `<TABLENAME>`';
$result = mysqli_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysqli_error() - "\n";
$message .= 'Whole Query: ' . $query;
die($message);
}
while ($row = mysqli_fetch_assoc($result)) {
echo $row['firstname'];
echo $row['lastname'];
}
mysqli_free_result($result);
?>