Jump to content

including


canadabeeau

Recommended Posts

I have a php function in functions.php

function func_page_layout(){
$uri = $_GET['uri'];
if($uri == ""){
	$uri = "home";
} else {
	$uri = $uri;
};
$mysqli = func_db_connect();
$qry = "SELECT * FROM `pages` WHERE `uri`='$uri' LIMIT 1";
$result = $mysqli->query($qry, MYSQLI_STORE_RESULT);
$array = mysqli_fetch_array($result);
	$layout = $array['layout'];
include('themes/default/layouts/'.$layout.'.php');
};

 

now this is not working

 

but if in the page instead of executing the function I do the include straight out it works, any ideas?

Link to comment
https://forums.phpfreaks.com/topic/186491-including/
Share on other sites

as an example $layout = layout001 is

<?php
echo '<div id="layout003">' . "\n" .
'<div class="left">' . "\n" .
'<div class="header">' . "\n" .
'<h2>technical leaders</h2>' . "\n" .
'</div>' . "\n" .
'<br />' . "\n" .
'kkk<br /><i>Senior Web-based Developer (mmm)</i>' . "\n" .
'</div>' . "\n" .
'<div class="right">' . "\n" .
'<h1>'.func_page_title().'</h1>' . "\n" .
'</div>' . "\n" .
'</div>';
?>

Link to comment
https://forums.phpfreaks.com/topic/186491-including/#findComment-984813
Share on other sites

Just echo every thing in the functions, it will help u find the problem where it occurs

 

Like,

 

echo $qry = "SELECT * FROM `pages` WHERE `uri`='$uri' LIMIT 1";
echo 'themes/default/layouts/'.$layour.'.php';

 

or give the full path to layout

 

it successfully echoes the text

Link to comment
https://forums.phpfreaks.com/topic/186491-including/#findComment-984821
Share on other sites

Warning: require(themes/default/layouts/layout001.php) [function.require]: failed to open stream: No such file or directory in C:\inetpub\wwwroot\_inc\functions.php on line 148

Fatal error: require() [function.require]: Failed opening required 'themes/default/layouts/layout001.php' (include_path='c:\php\includes') in C:\inetpub\wwwroot\_inc\functions.php on line 148

 

Line 148 is

require_once('themes/default/layouts/'.$layout.'.php');

Link to comment
https://forums.phpfreaks.com/topic/186491-including/#findComment-984832
Share on other sites

Warning: require(C:/inetpub/wwwroot/themes/default/layouts/layout001.php) [function.require]: failed to open stream: No such file or directory in C:\inetpub\wwwroot\_inc\functions.php on line 148

Fatal error: require() [function.require]: Failed opening required 'C:/inetpub/wwwroot/themes/default/layouts/layout001.php' (include_path='c:\php\includes') in C:\inetpub\wwwroot\_inc\functions.php on line 148

 

AND before suggestion above using

	require('themes/default/layouts/'.$layout.'.php');

 

Warning: require(themes/default/layouts/layout001.php) [function.require]: failed to open stream: No such file or directory in C:\inetpub\wwwroot\_inc\functions.php on line 148

 

Fatal error: require() [function.require]: Failed opening required 'themes/default/layouts/layout001.php' (include_path='c:\php\includes') in C:\inetpub\wwwroot\_inc\functions.php on line 148

 

Link to comment
https://forums.phpfreaks.com/topic/186491-including/#findComment-984858
Share on other sites

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.