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
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
Share on other sites

Then you need to do some debugging. Its likely your query is failing or some other issue.

 

Actually, Ive just noticed a couple of un-required ; after your closing }'s. Remove them. Have you got error reporting and display errors on?

Link to comment
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
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
Share on other sites

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.