Jump to content

require once vs include Relative php path


php-newbies

Recommended Posts

I believe there is a problem with the path to this file. what would be the alternative way to define the path?

 

require_once(dirname(__FILE__)."/pay_paypal.loadframework.php");

 

The physical path to this file is located in my root folder. i.e  root/components/com_ad/plugins/payment/pay_paypal.loadframework.php

 

is it possible to change require_once to include the relative path and how do I do this?

 

Many thanks in advance.

Link to comment
Share on other sites

Where is the script calling the require located?

 

Thanks this is the script "pay_paypal.notify.php" below

 

<?php

// no direct access
    header("Status: 200 OK");

    require_once(dirname(__FILE__)."/pay_paypal.loadframework.php");
    $database = & JFactory::getDBO();
    



    require_once(JPATH_ADMINISTRATOR.'/components/com_adsman/tables/addsman.php');
    require_once(JPATH_ADMINISTRATOR.'/components/com_adsman/tables/adsuser.php');
    require_once(dirname(__FILE__)."/pay_paypal.php");

$payment = new pay_paypal($database);
$payment->ipn($_REQUEST);

?>

 

Normally if the script runs ok, it should give me a blank page but will log it the backend

http://tt.easy2sell.net/components/com_adsman/plugins/payment/pay_paypal.notify.php

 

 

Many thanks for your help in advance.

Link to comment
Share on other sites

If they are in the same directory you don't need to supply a path, just give the file name.

require_once 'pay_paypal.loadframework.php';

 

Thanks yes, they are in the same directory/folder. Have tried with brackets require_once ('pay_paypal.loadframework.php');    or without brackets, require_once 'pay_paypal.loadframework.php';but still gives error. I am really not sure what is causing it.

 

Thanks once again.

Link to comment
Share on other sites

What is the error?

 

 

Warning: require_once(/home/bgcomp/public_html/tt/components/com_adsman/plugins/payment/../../../../../../libraries/import.php) [function.require-once]: failed to open stream: No such file or directory in /home/bgcomp/public_html/tt/includes/framework.php on line 39

 

Fatal error: require_once() [function.require]: Failed opening required '/home/bgcomp/public_html/tt/components/com_adsman/plugins/payment/../../../../../../libraries/import.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/bgcomp/public_html/tt/includes/framework.php on line 39

 

 

This the url: http://tt.easy2sell.net/components/com_adsman/plugins/payment/pay_paypal.notify.php

 

Link to comment
Share on other sites

I think you are looking at the file. You are trying to include import.php from framework.php. I don't know what this has to do with the files you mentioned.

 

This is the problem. I do not know why the script will invoke the  include import.php from framework.php when it is not even mentioned in the pay_paypal.notify.php

 

http://tt.easy2sell.net/components/com_adsman/plugins/payment/pay_paypal.notify.php

Link to comment
Share on other sites

require_once(dirname(__FILE__)."/pay_paypal.loadframework.php");
require_once(JPATH_ADMINISTRATOR.'/components/com_adsman/tables/addsman.php');
require_once(JPATH_ADMINISTRATOR.'/components/com_adsman/tables/adsuser.php');
require_once(dirname(__FILE__)."/pay_paypal.php");

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.