Jump to content

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