I am having problems to go up and down in folders using both relative and absolute path. Everything I try giver me an error:
failed to open stream: No such file or directory in C:\wamp\www\project\Telas\Funcionario\IncluirFuncionario.php
When I try using "dirname(FILE)" it returns a warning:
Warning: include_once(C:\wamp\www\qrFoodManager\Telas\Funcionario/../../Seguranca/VerificarAutenticacaoSubTela.php): failed to open stream: No such file or directory in C:\wamp\www\qrFoodManager\Telas\Funcionario\IncluirFuncionario.php on line 2
When I try relative paths, it gives me a warning like:
Warning: include_once(../../Seguranca/VerificarAutenticacaoSubTela.php): failed to open stream: No such file or directory in C:\wamp\www\qrFoodManager\Telas\Funcionario\IncluirFuncionario.php on line 2
This is the project tree (open on eclipse Helios): http://img268.imageshack.us/img268/5593/y3l3.png
I am trying to include VerificaAutenticacaoSubTela.php in IncluirFuncionario.php; currently using Wamp Server 2.4 installed on C: .. Help please!
Use $_SERVER['DOCUMENT_ROOT']
<?php include_once($_SERVER['DOCUMENT_ROOT']."/project/Seguranca/VerificarAutenticacaoSubTela.php"); ?>
include_once(dirname(__FILE__).'/../../Seguranca/VerificarAutenticacaoSubTela.php');
Try this
<?php
include_once($_SERVER['DOCUMENT_ROOT']."/project/Telas/Seguranca/VerificarAutenticacaoSubTela.php");
?>
*Note: * Assuming the path where the files are is: /project/Telas within your wamp/www
Related
i make MVC application (Without frameworks).
I try to include models from folder 'models' in controller, in folder controller.
include("/models/tasks_model.php");
But i get error:
Warning: include(): Failed opening '/models/tasks_model.php' for inclusion (include_path='.') in ...controller\create_task_controller.php on line 3
And
Warning: include(/models/tasks_model.php): failed to open stream: No such file or directory in ...\controller\create_task_controller.php on line 3
You need to fix your PHP paths
include("../models/tasks_model.php");
When you use this code:
include("/models/tasks_model.php");
It looks from the start of your disk because it an absolute path.
../ Goes back one folder from where your file is.
I am struggling trying to figure out why my require path link is not working.
My folder setup is the following:
Main domain on server test.example.com.
public_html -> test.example.com -> PHPMailer -> PHPMailerAutoload.php
Since the main domain is test.example.com, I am putting test.example.com in the path url. I have to do this for any link on the site (it was a setup mistake, but I haven't changed it yet).
The way I am trying to access this folder is below:
require 'test.example.com/test.example.com/PHPMailer-master/PHPMailerAutoload.php';
I get the following errors:
Warning: require(test.example.com/PHPMailer-master/PHPMailerAutoload.php): failed to open stream: No such file or directory in /home/example/public_html/test.example.com/php/newsletterSend.php on line 4
Warning: require(test.example.com/test.example.com/PHPMailer-master/PHPMailerAutoload.php): failed to open stream: No such file or directory in /home/example/public_html/test.example.com/php/newsletterSend.php on line 4
Fatal error: require(): Failed opening required 'test.example.com/test.example.com/PHPMailer-master/PHPMailerAutoload.php' (include_path='.:/opt/cpanel/ea-php71/root/usr/share/pear') in /home/example/public_html/test.example.com/php/newsletterSend.php on line 4
I need the link to be an absolute path because the file will be used in different folders.
Does anyone see what I am doing wrong?
it looks like your php is in a directory above the phpMailer folder.. so i think the path would be "../PHPMailer/PHPMailerAutoload.php"
you can use absolute paths if its simpler:
/home/foo/public_html/test.example.com/PHPMailer/PHPMailerAutoload.php
or relative paths if you know where you're starting!
../PHPMailer/PHPMailerAutoload.php
I have a problem with include path in PHP.
Code:
https://github.com/kukubaczek/KukuShop/blob/master/www/panel/index.php
If i open the panel/index.php page I see this error's:
Warning: require_once(/parts/header.php): failed to open stream: No
such file or directory in /PATH/KukuShop/www/panel/index.php on line 3
Fatal error: require_once(): Failed opening required
'/parts/header.php' (include_path='/..') in
/PATH/KukuShop/www/panel/index.php on line 3
How can I fix this? Here is problem with include path.
You are using absolute references when you probably want relative file locations. Try using this instead:
require_once("../parts/header.php")
What does the directory structure look like?
The set_include_path('/..'); statement doesn't seem to make sense.
Your PHP installation can't seem to find the files.
This error is quite common and it generally means it can't find the file it's looking for, but I can see the file in the directory?!
Full error:
Warning: require(/home/coinsfut/public_html/files/core.php) [function.require]: failed to open stream: No such file or directory in /home/coinsfut/public_html/new/index.php on line 4
line 4 says:
require $_SERVER['DOCUMENT_ROOT']. "/files/core.php";
the site is hosting in /new
any ideas?
Check the warning again. You are trying to include
/home/coinsfut/public_html/files/core.php
when in fact you want
/home/coinsfut/public_html/new/files/core.php
Please try
require $_SERVER['DOCUMENT_ROOT']. "/new/files/core.php";
and it should work just fine.
Alternative you could use
require "files/core.php";
to include files in a relative sub-directory since your index.php is in "new" directory.
My php files were working fine but today when i check them i get following errors.
Warning: require_once(Connections/deal.php) [function.require-once]: failed to open stream: No such file or directory in C:\complete project\ordering system\orderingcart.php on line 1
Fatal error: require_once() [function.require]: Failed opening required 'Connections/orders.php' (include_path='.;C:\php\pear') in C:\complete project\orderingcart.php on line 1
I don't know how to resolve these errors, where do I start?
It means, the path you gave in require_once() is invalid. You have two options,
1.Checkout whether the path Connections/deal.php is correct or not. Do you have a folder Connections in the folder where this running file is placed? Is there a deal.php inside that folder Connections?
I think your running file path is C:\complete project\ordering system\orderingcart.php. It does not have such a folder and file. So place your Connections folder in C:\complete project\ordering system\ and checkout.
2.Else, You can run the page without fatal error if you change the line to include_once(Connections/deal.php). Functions assosciated with deal.php will be inactivated.
This sounds like the file has either moved OR the file permission have been altered as to prevent the server account (usually www-data) from having access to it.
You might also have better luck by trying to access the file by suppling an absolute path, rather than a relative path, e.g:
<?php
$lines = file("C:\\Documents and Settings\\myfile.txt");
foreach($lines as $line){
echo($line);
}
?>
This file path issue give full file location like
if it is windows
require_once('C:/complete project/Connections/deal.php');
For reference
http://php.net/manual/en/function.realpath.php