i'm new in php as you know and i have some problems (like any new starts) and my problem is i cant include file like config.php
to all functions in the files
i have just 3 files
in config.php
i just connect to database in mysqli and the variable is $connect
in functions.php there is just a simple functions
include('config.php');
function rows($table){
$gettables = mysqli_query($connect,"SELECT * FROM $table");
$numrows = mysqli_num_rows($gettables);
return($numrows);
}
in index.php
include('functions.php');
echo rows('books');
and the problem is i cant get $connect
variable from config.php
to work in functions in functions.php
file.
EDIT
when i include config.php
inside the functions everything will be ok,
like this
function rows($table){
include('config.php');
$gettables = mysqli_query($connect,"SELECT * FROM $table");
$numrows = mysqli_num_rows($gettables);
return($numrows);
}
but i don't want to do this because i want to include a config.php
for all functions i have.
Thanks