I am trying to get an array from a database. I got the table name from a previous PHP file and I am trying to return the array. However, it only responds with an error.
If I replace the $db_name in the query with the name as a string it works fine but that is not what I want. I don't know why it is not working. Is it just not liking the query? It only does not work when I put in the table name as a variable.
$db_name = $_SESSION['databaseMenu'];
echo $db_name;
$sql="SELECT feed FROM '".$db_name."' ";
$result=mysqli_query($con,$sql);
// Fetch all
$outp = mysqli_fetch_all($result,MYSQLI_ASSOC);
$arra = array_values($outp);
return $arra;
Like I said earlier, when the query is a simple text it returns the array however when I put in the variable it responds with the error: ''' Warning: mysqli_fetch_all() expects parameter 1 to be mysqli_result, boolean given in '''
Any advice is appreciated.