Подключение к БД
<?php
$mysqli = false;
function connectDB(){
global $mysqli;
$mysqli = new mysqli('localhost','root','root','gb');
$mysqli->query("SET NAMES utf8");
}
function closeDB(){
global $mysqli;
$mysqli->close();
}
?>
Вывод записей:
<?php
require_once '../connect_db.php';
function getProjects() {
global $mysqli;
connectDB();
$result = $mysqli->query("SELECT * FROM `projects` ORDER BY `id` DESC");
closeDB();
return resultToArray($result);
}
function resultToArray($result){
$array = array ();
while (($row = $result->fetch_assoc()) != false)
$array[] = $row;
return $array;
}
?>
Вывод записей..
require_once "admin/functions/project/database_project.php";
$projects = getProjects();
Ошибка:
Warning: require_once(../connect_db.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/site/admin/functions/project/database_project.php on line 2
Fatal error: require_once(): Failed opening required '../connect_db.php' (include_path='.:/Applications/MAMP/bin/php/php7.1.6/lib/php') in /Applications/MAMP/htdocs/site/admin/functions/project/database_project.php on line 2
Файлы расположены: