Jump to content

*SOLVED* Require Problem


steelmanronald06

Recommended Posts

I can't believe that this has happened to me. I should be good enough now that this shouldn't be a problem, but of course I am just not seeing the problem.

[b]Error[/b]
[quote]
Warning: require_once(includes/tmp/top_layout.php) [function.require-once]: failed to open stream. No such file or directory in C:\wamp\www\blakes\includes\config.php on line 43

Fatal error: require_once() [function.require]: Failed opening required 'includes/tmp/top_layout.php' (include_path='.;C:\php5\pear') in C:\wamp\www\blakes\includes\config.php on line 43
[/quote]

[b]config.php line 43[/b]
[code]
function topLayout() {
require_once($path . 'includes/tmp/top_layout.php);
}
[/code]

Now if I do this from C:\wamp\www\blakes\index.php it works. But if I try from C:\wamp\www\blakes\admin\login.php I get the error.  Here is what the login.php does:
[code]
$path = "../";

require_once($path . 'includes/config.php');

topLayout();
[/code]

So does anyone else see what I'm not seeing?
Link to comment
https://forums.phpfreaks.com/topic/29281-solved-require-problem/
Share on other sites

But, you're within a function, variables defined outside the function are not available to the function unless they are declared global inside the function or passed in via an argument.

[code]<?php
function topLayout() {
  global $path;  // add this statement
  require_once($path . 'includes/tmp/top_layout.php);
}?>[/code]

Ken

Archived

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

×
×
  • 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.