canadabeeau Posted December 28, 2009 Share Posted December 28, 2009 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? Quote Link to comment Share on other sites More sharing options...
canadabeeau Posted December 28, 2009 Author Share Posted December 28, 2009 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>'; ?> Quote Link to comment Share on other sites More sharing options...
canadabeeau Posted December 28, 2009 Author Share Posted December 28, 2009 if this is not very clear, let me know and I can provide clarification Quote Link to comment Share on other sites More sharing options...
trq Posted December 28, 2009 Share Posted December 28, 2009 How are you calling this function? Quote Link to comment Share on other sites More sharing options...
scvinodkumar Posted December 28, 2009 Share Posted December 28, 2009 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 Quote Link to comment Share on other sites More sharing options...
canadabeeau Posted December 28, 2009 Author Share Posted December 28, 2009 How are you calling this function? <?php ob_start(); session_start(); $require_once = '_inc/functions.php'; require_once($require_once); ?> <?php func_page_layout(); ?> Quote Link to comment Share on other sites More sharing options...
canadabeeau Posted December 28, 2009 Author Share Posted December 28, 2009 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 Quote Link to comment Share on other sites More sharing options...
trq Posted December 28, 2009 Share Posted December 28, 2009 Remove the call to ob_start(). Quote Link to comment Share on other sites More sharing options...
canadabeeau Posted December 28, 2009 Author Share Posted December 28, 2009 Remove the call to ob_start(). did and still does not work Quote Link to comment Share on other sites More sharing options...
trq Posted December 28, 2009 Share Posted December 28, 2009 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? Quote Link to comment Share on other sites More sharing options...
scvinodkumar Posted December 28, 2009 Share Posted December 28, 2009 I think the path to layout is not correct, instead of include change to require. Quote Link to comment Share on other sites More sharing options...
canadabeeau Posted December 28, 2009 Author Share Posted December 28, 2009 I think the path to layout is not correct, instead of include change to require. I have tried this, with no luck (I am now going to use require_once NOT include) Quote Link to comment Share on other sites More sharing options...
scvinodkumar Posted December 28, 2009 Share Posted December 28, 2009 i think error reporting will be disable, enable it first i dont know how u coded, just try like this, echo func_page_layout(); Quote Link to comment Share on other sites More sharing options...
canadabeeau Posted December 28, 2009 Author Share Posted December 28, 2009 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'); Quote Link to comment Share on other sites More sharing options...
scvinodkumar Posted December 28, 2009 Share Posted December 28, 2009 i told u na, your path to layout is wrong, check the correct path and change it Quote Link to comment Share on other sites More sharing options...
canadabeeau Posted December 28, 2009 Author Share Posted December 28, 2009 if I place http://10.0.0.1/themes/default/layouts/layout001.php it comes up!!!! Quote Link to comment Share on other sites More sharing options...
canadabeeau Posted December 28, 2009 Author Share Posted December 28, 2009 if the absolute path is C:\Inetpub\wwwroot\themes\default\layouts\layout001.php and C:\Inetpub\wwwroot\_inc\functions.php what should the require_once URL be? require('/themes/default/layouts/'.$layout.'.php'); Quote Link to comment Share on other sites More sharing options...
scvinodkumar Posted December 28, 2009 Share Posted December 28, 2009 require('../themes/default/layouts/'.$layout.'.php'); Quote Link to comment Share on other sites More sharing options...
canadabeeau Posted December 28, 2009 Author Share Posted December 28, 2009 require('../themes/default/layouts/'.$layout.'.php'); unfortuanatley not Quote Link to comment Share on other sites More sharing options...
scvinodkumar Posted December 28, 2009 Share Posted December 28, 2009 try like this require($_SERVER['DOCUMENT_ROOT'].'themes/default/layouts/'.$layout.'.php'); Quote Link to comment Share on other sites More sharing options...
canadabeeau Posted December 28, 2009 Author Share Posted December 28, 2009 try like this require($_SERVER['DOCUMENT_ROOT'].'themes/default/layouts/'.$layout.'.php'); still no luck Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted December 28, 2009 Share Posted December 28, 2009 And what was the php error message when you tried the last suggestion - require($_SERVER['DOCUMENT_ROOT'].'themes/default/layouts/'.$layout.'.php'); Quote Link to comment Share on other sites More sharing options...
canadabeeau Posted December 28, 2009 Author Share Posted December 28, 2009 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 Quote Link to comment Share on other sites More sharing options...
canadabeeau Posted December 28, 2009 Author Share Posted December 28, 2009 I made the layout001.php just be <?php echo "test";?> and even that wont work :-( Quote Link to comment Share on other sites More sharing options...
canadabeeau Posted December 28, 2009 Author Share Posted December 28, 2009 anyone? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.