Require is unable to retrieve the file

Asked

Viewed 67 times

0

Hello, no require error happens:

Warning: require(./funcs/FuncSQL.php): failed to open stream: No such file or directory in /opt/lampp/htdocs/Lucktor/pages/home.php on line 42

Fatal error: require(): Failed opening required './funcs/FuncSQL.php' (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/Lucktor/pages/home.php on line 42

But as you can see in the image below he is there:

inserir a descrição da imagem aqui

I set the path like this

define ("DIR_PAGES", DIR.'pages/');

And I call it this way:

require DIR_FUNCS.'FuncSQL.php';
  • And you’re calling the file FuncSql.php inside pages/home.php? If yes, try ../funcs/FuncSql.php. Or use $_SERVER['DOCUMENT_ROOT'].funcs/FuncSQL.php

  • When I tried ../funcs/FuncSQL.php nothing changed and when I used $_SERVER['DOCUMENT_ROOT'].funcs/FuncSQL.php just appeared more mistakes.

  • This is misdirection... Try to do the following test... do echo $_SERVER['DOCUMENT_ROOT'].'/funcs/FuncSQL.php' and see if the directory he shows this correct... In my previous comment I forgot to put the / <- barra before funcs, must be because of the error. But this error is of wrong file include pointing.

  • I think I found the problem, it’s returning /opt/lampp/htdocs/funcs/FuncSQL.php, and should return /opt/lampp/htdocs/Lucktor/funcs/FuncSQL.php

  • Usually the $_SERVER['DOCUMENT_ROOT'] brings the path to the root folder. If you solved the problem closes the question.

  • @Maxrogério I used this way require '/opt/lampp/htdocs/Lucktor/funcs/FuncSQL.php'; and keeps returning the same error.

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.