I'm trying to pass a variable from a dbh.inc.php to index.php using include_once, But it gives me an error in $con at index.php that it is not defined
dbh.inc.php:
<?php
$dbServername = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbName = "loginsystem";
$con = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);
indux.php:
<?php
include_once 'includes/dbh.inc.php';
?>
<!DOCTYPE html>
<html lang="">
<head>
<title></title>
</head>
<body>
<?php
$sql = 'SELECT * FROM users;';
$result = mysqli_query($con, $sql);
$resultCheck = mysqli_num_rows($result);
if($resultCheck > 0)
{
while ($row = mysqli_fetch_assoc($result))
{
echo $row['user_uid'] . "<br>";
}
}
?>
</body>
</html>