How to have relative path (../) in a pipe script? - php

I have [root]/includes/helpdesk/pipe.php with this code:
#!/opt/cpanel/ea-php55/root/usr/bin/php
<?php
require_once("pipeprocess.php");
In the same location in pipeprocess.php in first line I include another file still in the same location: helpdesk.php
then in [root]/includes/helpdesk/helpdesk.php in the first line I have:
require_once ("../../config.php");
config.php is in [root], this is why I have twice ../../, helpdesk.php works fine with direct access, but if run pipe.php via pipe command setup in cPanel I get a bounce error that config. php is not found:
PHP Warning: require_once(../../config.php): failed to open stream:
No such file or directory in
/home/[user]/public_html/[root]/includes/helpdesk/helpdesk.php on line
21
Warning: require_once(../../config.php): failed to open stream: No
such file or directory in
/home/[user]/public_html/[root]/includes/helpdesk/helpdesk.php on line
21 PHP Fatal error: require_once(): Failed opening required
'../../config.php' (include_path='.:/usr/lib/php:/usr/local/lib/php')
in /home/[user]/public_html/[root]/includes/helpdesk/helpdesk.php on
line 21
Fatal error: require_once(): Failed opening required
'../../config.php' (include_path='.:/usr/lib/php:/usr/local/lib/php')
in /home/[user]/public_html/[root]/includes/helpdesk/helpdesk.php on
line 21
Why I am getting this pipe error as direct access to helpdesk.php works fine? does pipe not accept ../ or ../../ as parth of the path? or is there an EasyApache4 issue? I did several tests and noticed this is because of ../ as part of including path. Does pipe/EasyApache4 have problem with this?

What if you used __DIR__, based on where your currently running script file's folder?
As of PHP 5.3.0, you could use something like this:
require_once (__DIR__ . "/../../config.php");

Related

Connecting MySQL to php files (pear error)

Warning: require_once(book/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\book\book.php on line 48
Fatal error: require_once(): Failed opening required 'book/autoload.php' (include_path='C:\xampp\php\PEAR;;/book;/book/classes;/book/pear/PEAR') in C:\xampp\htdocs\book\book.php on line 48
I added this to the file:
require_once('book/autoload.php');
include_path('C:\xampp\php\PEAR;;/book;/book/classes;/book/pear/PEAR');
This is very rudimentary, but it's still not working. Have mercy, this is my first php project.
You can try this
require_once('book/autoload.php');
and must check that your folder path is correct.

PHP fatal error opening required file

I'm having problems debugging this php error. '/app/bootstrap.php' exists so not sure why I'm getting this error? Can anyone help? Thanks
[24-Mar-2017 10:42:50 Europe/London] PHP Warning: require_once(/app/bootstrap.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/example.com/index.php on line 2
[24-Mar-2017 10:42:50 Europe/London] PHP Fatal error: require_once(): Failed opening required '/app/bootstrap.php' (include_path='.:/Applications/MAMP/bin/php/php5.6.30/lib/php') in /Applications/MAMP/htdocs/example.com/index.php on line 2
The path /app/bootstrap.php looks like a root path ( and the root isn't your website root, but your Mac root directory).
Change require path to __DIR__ . '/app/bootstrap.php', it means to require a sccript that in /app/bootstrap.php relative to CURRENT directory.

Drupal cron error: failed to open stream

I've set up my Drupal 7 cron job like so:
/usr/local/bin/php /home/myaccount/public_html/cron.php
However, cron sends me an email with the following error message:
Warning: include_once(/home/myaccount/includes/bootstrap.inc): failed to open stream: No such file or directory in /home/myaccount/public_html/cron.php on line 13
Warning: include_once(): Failed opening '/home/myaccount/includes/bootstrap.inc' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/myaccount/public_html/cron.php on line 13
Fatal error: Call to undefined function drupal_bootstrap() in /home/tente myaccount studios/public_html/cron.php on line 14
It appears that cron is somehow stripping out public_html from the path. I uploaded a temporary PHP file and printed out getcwd() and it reports the path correctly, including public_html. So somewhere between line 11 when DRUPAL_ROOT is defined as getcwd() and line 13 when the include is called, something strips out public_html from the path.
You should use curl to call your webserver so that the correct php.ini and openbasedir directives are set. See https://www.drupal.org/cron

error: require(): Failed opening required file

i am getting the following errors when i am trying to include a file.. i have tried chmod 777 for the directory..checked twice ,the path is correct ..but still the errors persist
the errors are:
Warning: require(../lib/GoogleChart.php): failed to open stream: No such file or directory in /opt/lampp/htdocs/project1/admin/googlechart/examples/line_chart_full.php on line 3
Fatal error: require(): Failed opening required '../lib/GoogleChart.php' (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/project1/admin/googlechart/examples/line_chart_full.php on line 3
What might be wrong is it with the permission cause i have done chmod -R 777 on the directory
You coul try with absolute path starting from documen root (if you have no needs to run the script in command line because $_SERVER array is not provided if the script is launched by a shell)
require($_SERVER['DOCUMENT_ROOT'] . "/lib/GoogleChart.php";
Giving that the lib directory is in the root (www.example.com/lib/GoogleChart.php).
I would suggest require_once instead

require_once() cant find the include path

Hi i am trying to indlude a file by using require_once(). i am using xampp apache php server.
the file test.php is in htdocs drupal folder is also in the same directory where the include files is.
the code in line 5 is
require_once ‘drupal7/includes/bootstrap.inc’;
i am getting error
Warning: Division by zero in C:\xampp\htdocs\import.php on line 5
Warning: require_once(inc’) [function.require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\import.php on line 5
Fatal error: require_once() [function.require]: Failed opening required 'inc’' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\import.php on line 5
someone please guide me how to include a local file.
Looks like you have "fancy" single quotes in line 5. (Did you copy this from somewhere?) Change them to regular single quotes, like these:
require_once 'drupal7/includes/bootstrap.inc';

Categories