1
I have the following include:
include('../header.php');
on the pages that are the same folder as the include header works, but when there is a folder above it doesn’t work.
The include page is inside the pages/1998
the following errors are issued:
Warning: include_once(../acoes/conexao.php): failed to open stream: No such file or directory in C: xampp htdocs PMI-WEB-CONTAB-ALPHA pages header.php on line 5
Warning: include_once(): Failed Opening '.. /acoes/conexao.php' for inclusion (include_path='C: Xampp php PEAR') in C: xampp htdocs PMI-WEB-CONTAB-ALPHA pages header.php on line 5
Warning: include_once(../acoes/modal.php): failed to open stream: No such file or directory in C: xampp htdocs PMI-WEB-CONTAB-ALPHA pages header.php on line 6
Warning: include_once(): Failed Opening '.. /acoes/modal.php' for inclusion (include_path='C: Xampp php PEAR') in C: xampp htdocs PMI-WEB-CONTAB-ALPHA pages header.php on line 6
Warning: require(../acoes/pagina_verificar.php): failed to open stream: No such file or directory in C: xampp htdocs PMI-WEB-CONTAB-ALPHA pages header.php on line 11
Fatal error: require(): Failed Opening required '.. /acoes/pagina_verify.php' (include_path='C: Xampp php PEAR') in C: xampp htdocs PMI-WEB-CONTAB-ALPHA pages header.php on line 11
worked in parts, but the page did not take CSS and Bootstrap, issued the following errors: Warning: include(../.header.php): failed to open stream: No such file or directory in C: xampp htdocs PMI-WEB-CONTAB-ALPHA pages 1998 reports_financeiros_98.php on line 2 Warning: include(): Failed Opening '.. /.. /header.php' for inclusion (include_path='C: Xampp php PEAR') in C: xampp htdocs PMI-WEB-CONTAB-ALPHA pages 1998 reportarios_financeiros_98.php on line 2 Notice: Undefined variable: _SESSION in C: xampp htdocs PMI-WEB-CONTAB-ALPHA pages 1998 reports_financeiros_98.php on line 4
– V.Avancini
That first Warning that you presented is that now the header page is not being found. In which folder is the file that calls your include?
– David Alves
he stays in the 1998 folder
– V.Avancini
So the include scam is really
../header.php
. This include is not wrong. The problem is elsewhere– David Alves
have any idea what it could be?
– V.Avancini
pq pages that are in the same folder as the header are working perfectly
– V.Avancini
Got it. The problem is include inside header.php, because when it is called from inside a file inside the 1998 folder, the call
../acoes/conexao.php
in header.php line 5 is incorrect from the inside view of the 1998 folder, you would need a../
the most– David Alves
To do this, use friend @Valdeir Psr’s suggestion to create a constant on your system that allows you to always know the path of include from it
– David Alves