doddsey_65 Posted February 11, 2012 Share Posted February 11, 2012 I am simple using include to include a file within the webpage. include $file; $file does exist and is a string. This works fine locally but when testing on my live server it isnt included and nothing below the include is executed, not even plain html. The error log shows nothing, and there are no errors on screen even when using E_ALL. So i decided to make $file point to the file on the server to see if it was picking it up and it does. So why doesnt the live server want to include this file? The file consists of php and html but there arent any errors. It wouldnt work locally if there were. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/256903-weird-include-problem/ Share on other sites More sharing options...
PFMaBiSmAd Posted February 11, 2012 Share Posted February 11, 2012 Your file being included probably contains a fatal parse or runtime error, due to a configuration difference between your development system and the live server. Add the following three lines of code immediately after the first opening <?php tag in your MAIN file - ini_set("display_startup_errors", "1"); ini_set("display_errors", "1"); error_reporting(-1); Quote Link to comment https://forums.phpfreaks.com/topic/256903-weird-include-problem/#findComment-1317022 Share on other sites More sharing options...
doddsey_65 Posted February 11, 2012 Author Share Posted February 11, 2012 already tried that ( should have mentioned ) I get a few undefined index notices and an undefined variable notice. Nothing that would stop execution. And those notices are generated from the previous file, which runs fine. Quote Link to comment https://forums.phpfreaks.com/topic/256903-weird-include-problem/#findComment-1317023 Share on other sites More sharing options...
Pikachu2000 Posted February 11, 2012 Share Posted February 11, 2012 var_dump(include $file); should return an INT 1 if successful. Does $file contain a local filesystem path? Quote Link to comment https://forums.phpfreaks.com/topic/256903-weird-include-problem/#findComment-1317026 Share on other sites More sharing options...
doddsey_65 Posted February 11, 2012 Author Share Posted February 11, 2012 dumping of the include returns nothing, not even null or false, just doesnt display. I have tried: $include= include $file; if(!$include) die(1) nothing displays dump(include($file)); nothing displays if(include $file) echo 'yes' else echo 'no'; still get nothing And i am using absolute paths for everything given the nature of the project. The included file has no filepath references either. Quote Link to comment https://forums.phpfreaks.com/topic/256903-weird-include-problem/#findComment-1317027 Share on other sites More sharing options...
PFMaBiSmAd Posted February 11, 2012 Share Posted February 11, 2012 Are you even using <?php tags in your code? What does a 'view source' in your browser of the page show? Quote Link to comment https://forums.phpfreaks.com/topic/256903-weird-include-problem/#findComment-1317030 Share on other sites More sharing options...
doddsey_65 Posted February 11, 2012 Author Share Posted February 11, 2012 view source shows nothing after the include. included file contents <?php $recentTopics = AsfApi::call('topics/get', array('order' => 't_time_posted,desc', 'limit' => 5)); foreach($recentTopics as $k => $v) { $poster[$k] = AsfApi::call('user/info', array('fields' => array('u_username'), 'u_uid' => $v['t_poster'])); $recentTopics[$k]['t_poster_id'] = $v['t_poster']; $recentTopics[$k]['t_poster'] = $poster[$k]['u_username']; } ?> <div class="sidebar"> <div class="header"> <h2>Recent Topics</h2> </div> <?php foreach($recentTopics as $recent) { ?> <dl> <dt> <img src="/uploads/avatars/doddsey_65.png" alt="" title="doddsey_65's avatar" class="avatar_small"> </dt> <dd> <p class="list_title"> <a href="/topic/<?php echo createUrl($recent['t_name']); ?>|<?php echo $recent['t_tid']; ?>/"> <?php echo truncate($recent['t_name']); ?> </a> </p> <p class="info"> <?php echo profileLink($recent['t_poster_id']); ?> <span class="date"><?php echo formatDate($recent['t_time_posted']); ?></span> </p> </dd> </dl> <? } ?> </div> Quote Link to comment https://forums.phpfreaks.com/topic/256903-weird-include-problem/#findComment-1317031 Share on other sites More sharing options...
doddsey_65 Posted February 11, 2012 Author Share Posted February 11, 2012 even if the included file is empty or just contains html it still breaks the execution of anything else. Commenting out the include means the page loads fine. Quote Link to comment https://forums.phpfreaks.com/topic/256903-weird-include-problem/#findComment-1317037 Share on other sites More sharing options...
jcbones Posted February 11, 2012 Share Posted February 11, 2012 Change: </dl> <? } ?> </div> To: </dl> <?php } ?> </div> See if that works. If short tags are turned off, you should be getting a parse error for the missing } Quote Link to comment https://forums.phpfreaks.com/topic/256903-weird-include-problem/#findComment-1317100 Share on other sites More sharing options...
PFMaBiSmAd Posted February 12, 2012 Share Posted February 12, 2012 If you didn't get any php errors out of this, then your web host has likely disabled ini_set/error_reporting or you have used your own error handler and didn't take into account all the types of errors. Also, don't ever use lazy-way short opening <? tags. They WASTE several orders of magnitude more time then you ever saved in typing time by leaving out the three letters 'php' a few times per code file. Quote Link to comment https://forums.phpfreaks.com/topic/256903-weird-include-problem/#findComment-1317198 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.