I'm sure this is a duplicate, but I can not find an answer to this. For whatever reason, I can not query my database.
Simply I am trying to call a function but I get the error...
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in ... on line 12
My dbConnect.php file has
$adConn = mysqli_connect("myHost","myUser","myPword","myDB");
My functions.php files has
require "dbConnect.php";
// Check connection
if (mysqli_connect_errno($adConn))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
//-------------------------------------------------//
// Gets total number of games for a given week //
//-------------------------------------------------//
function GetGamesCount($wID){
$sql = "SELECT * FROM schedule WHERE weekID=$wID";
$gamesRS = mysqli_query($adConn, $sql);
$games = mysqli_fetch_array($gamesRS);
}
I get no error from the connection check, I have tried putting it within the funcation as well. I know I can use the mysqli_num_rows function, which I will. I just need to figure out why it won't query the database. I have tried querying with other functions with the same problem. However, if I query within the page or using ajax from a separate file, I have no problems.
I just don't see what I'm missing. Any help is greatly appreciated.