This has me pretty baffled, so I have a simple include line in my php but it for some reason does not always work right.
Basically the include is loading my main content section...
if $page['view'] is list my page will not load correctly...
the php I have is
include ('lib/views/' . $page['view'] . '.php');
However the page does not load and nothing below this point loads including the footer...
This works as expected
echo 'lib/views/' . $page['view'] . '.php';
My apache2 error log spits out the following error
include(): Failed opening 'lib/views/.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/site/www/lib/includes/main.php on line 3
When I try this, the footer reappears but still same error
$view = 'lib/views/' . $page['view'] . '.php';
include ($view);
This is pretty baffling to me, especiall considering that if $page['view'] is avatar it then works
EDIT 1
As suggested by @philwc I have added this to my code
if (isset($page['view'])) {
var_dump($page['view']);
}
Which outputs as expected list
Try this:
include ("lib/views/{$page['view']}.php");
As you stated it will give you a different error, just mark this correct so that it doesn't sit in limbo :)
It looks like $page['view'] is not set correctly. Try wrapping it with an isset like
if(isset($page['view'])){
include ('lib/views/' . $page['view'] . '.php');
}else{
echo 'Error!';
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With