Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Error including file


xiao

Recommended Posts

Posted

I'm writing a script which allows people to bulk add products to their cart from a part of the website outside of osCommerce.

 

I use this code:

		require("../oscommerce/includes/application_top.php");
	foreach ($_SESSION['productid'] as $id){
			$cart->add_cart($id, $cart->get_quantity((int)$id)+1);
	}
	tep_redirect(tep_href_link('shopping_cart.php'));

 

But I get this error:

Warning: require(includes/configure.php) [function.require]: failed to open stream: No such file or directory in /var/www/oscommerce/includes/application_top.php on line 28

 

Fatal error: require() [function.require]: Failed opening required 'includes/configure.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/oscommerce/includes/application_top.php on line 28

 

My script is in /var/www/pconfig/

And oscommerce is in /var/www/oscommerce/

 

The script is based on this:

http://addons.oscommerce.com/info/4850

 

Edit:

It works when I put the script in the oscommerce directory (and change the include path), but I want it somewhere else...

Posted
Warning: require(includes/configure.php) [function.require]: failed to open stream: No such file or directory in /var/www/oscommerce/includes/application_top.php on line 28

 

this happens because your code in pconfig/mycode.php includes ../oscommerce/includes/application_top.php.

but application_top.php includes includes/configure.php....the absolute path name for this would be pconfig/includes/configure.php - which of course doesn't exist.

 

the easist way to fix this would be to add a line of code to the beginning of pconfig/mycode.php, like this:

 

set_include_path(get_include_path() . PATH_SEPARATOR . '../oscommerce');

 

this sets up an 'include path' ... just like the old windows path= environment variable. now, in addition to your current directory, the ../oscommerce/ directory will be used to try to resolve all included file names. in fact, you could now just include('includes/application_top.php') instead of using that whole long relative path name.

 

i hope this helps.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...