I'm having a problem regarding my database connection not recognized on my functions.php even though i have included it already. here's the code.
dbconnect.php
<?php
define ("DB_SERVER","localhost");
define ("DB_USER","root");
define ("DB_PASS","");
define ("DB_NAME","hookdb");
$conn = mysqli_connect(DB_SERVER,DB_USER,DB_PASS,DB_NAME);
//test connection
if(mysqli_connect_errno()){
die("Database connection failed: " .mysqli_connect_error() . "( " . mysqli_connect_errno(). ")");
}?>
functions.php
<?php
require_once("dbconnect.php");
function check_query($result_set){
if(!$result_set){
die("Database query failed. ");
}
}
function random_banner(){
$query = "SELECT COUNT(*) as total FROM manga_name";
$result = mysqli_query($conn, $query);
check_query($result);
$data = mysqli_fetch_assoc($result);
return($data);
//echo $data['total'];
}?>
im still getting the "Notice: Undefined variable: conn" error when i use the function on my page.