I have this function (in file functions.php) that returns me a list of the users in a database.
function db_listar_usuarios(){
$link = db_connect();
$query = "select * from usuarios" or die("Problemas en el select: " . mysqli_error($link));
$result = $link->query($query);
$myArray = array();
while($row = mysqli_fetch_assoc($result)) {
$myArray[$row['nombre']] = $row;
//print_r($myArray); // for debugging
}
return $myArray;
//print_r($myArray);
}
and i want to use it in a Class that is in another file (server.php)
<?php
include('functions.php');
class Server {
private $contacts = db_listar_usuarios(); //<-- this doesn't work =(
...
}
What can I do to make this code work?
Thanks!