I have a weird problem with the require()
command, it does not work at all and gives me a weird error.. yes i am 100% sure i put the right path
i tried using both relative and full paths, as well as using include()
, include_once()
, require()
, require_once()
but to no avail..
I tested the file's existence and it does exist.. it is making no sense to me!
I haven't seen anyone else having the same problem as this on forum, I also tried using global variables like $_SERVER["DOCUMENT_ROOT"]
and other paths but this still doesn't work for me.
The procedure is: HTML button -> ajax calls "addcomments.php" -> page requires "ajax.php"-> error
addcomments.php page:
//set path
$path = "g:/appserv/www/y4project/scripts/php/funcs/";
//check directory
print_r(scandir($path));
//check if php file exists
if(file_exists($path."ajax.php"))
echo "######### IT EXISTS!!! ##########";
else echo "@@@@@@ NO! @@@@@@@@";
//require it
require($path."ajax.php");
The error:
Array (
[0] => .
[1] => ..
[2] => account.php
[3] => ajax.php
[4] => main.php
[5] => service.php )
######### IT EXISTS!!! ##########
Warning: require(1) [function.require]: failed to open stream: No such file or directory in G:\AppServ\www\y4project\scripts\AJAX\addcomments.php on line 10
Fatal error: require() [function.require]: Failed opening required '1' (include_path='.;C:\php5\pear') in G:\AppServ\www\y4project\scripts\AJAX\addcomments.php on line 10
I also tried relative paths like "../php/funcs/ajax.php", same problem.. scandir()
and file_exists()
both find it but require()
fails!
Your help is most appreciated!
EDIT
I just tested it to be sure, required it from a different test page and used a function and it worked, but still not working from the "addcomments.php" page which gets called by AJAX.
Another EDIT
I also checked the documentation for the PHP require_once()
and require()
, I still can't see the problem!
Could it be a path bug of some sort or a security measure where AJAX called scripts cannot call other scripts what so ever? but that makes no sense?
I did not read anything about that in the documentation either.
I even tried requiring HTML pages and still not working.
I'm lost..