Hey there everyone, I’m having issues with an include file for database connections. I’ve got a function in an include file that connects to a mySql db. It works fine with a file in the same directory, but not in a different directory. Seems like a scope issue, as it is able to find the include file in both cases, but I haven’t been able to figure it out yet :).
Thanks in advance
/login/incDB.php
[php]
[/php]
/login/index.php
[php]
include_once ‘incDB.php’;
getConn();
$sql = "call getLoginInfo ('$username','$password');";
if(!$result = $conn->query($sql)){
die('There was an error running the query [' . $conn->error . ']');
} else {
echo 'logged in fine';
}
[/php]
/upload/index.php
[php]
[/php]
//error for mysqli_query($conn, $sql);
Notice: Undefined variable: conn in…
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in…
//error for mysqli_close($conn);
Notice: Undefined variable: conn in…
Warning: mysqli_close() expects parameter 1 to be mysqli, null given in…