Jump to content

Recommended Posts

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?

 

Link to comment
https://forums.phpfreaks.com/topic/256903-weird-include-problem/
Share on other sites

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);

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.

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.

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>

 

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.

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.