0
votes

I am trying to use this:

 include_once("PoliticalForum/StoredProcedure/User/number_login_attempts.php");

Warning: include_once(../../untitled/sanitize_string.php) [function.include-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\PoliticalForum\StoredProcedure\User\number_login_attempts.php on line 3

Warning: include_once() [function.include]: Failed opening '../../untitled/sanitize_string.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\PoliticalForum\StoredProcedure\User\number_login_attempts.php on line 3

and this:

  include_once("/PoliticalForum/untitled/sanitize_string.php");

Warning: include_once(/PoliticalForum/untitled/sanitize_string.php) [function.include-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\PoliticalForum\StoredProcedure\User\number_login_attempts.php on line 3

Warning: include_once() [function.include]: Failed opening '/PoliticalForum/untitled/sanitize_string.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\PoliticalForum\StoredProcedure\User\number_login_attempts.php on line 3

How can I import files safely without having those errors?

5

5 Answers

1
votes

Pick one:

  • Provide a valid path (paths that start with / are absolute, otherwise they are relative).
  • Add the folder to the include_path.
  • Use class autoloading (if applicable).
0
votes

You should make sure the files can be found on the include path, because these errors mean the file cannot be found by PHP.

More info about include can be found in the PHP manual: http://php.net/manual/en/function.include.php

0
votes

I think those files you include each inlude other files (possibly with require or require_once). These files cannot be found which causes the include to fail.

Include is ignored if the file doesn't exist, but it fails if the file does exists but contains errors.

0
votes
include_once("PoliticalForum/StoredProcedure/User/number_login_attempts.php");

Above statement means the directory PoliticalForum is in the same directory of the file which has this statement.

You need to look into the directory structure you are using.

Alternatively, you could use $_SERVER['DOCUMENT_ROOT'] to locate all directories starting from root directory.

ForExample:

`$_SERVER['DOCUMENT_ROOT']`/dirLevel1 // sub directory on root
-1
votes

Try this

include_once "PoliticalForum/StoredProcedure/User/number_login_attempts.php";

include_once"PoliticalForum/untitled/sanitize_string.php";