NameSilo

Need help with calling a file. - Php include

Spaceship Spaceship
Watch

nyunyu

Established Member
Impact
4
I got a directory installed within xytheme.com. I want to call the stats and put it on my main blog. As you can see from www.xytheme.com, there is a sidebar there and I want to put my directory stats on it.

This theme is not a widget ready so everything has to be coded. I don't really good in coding, a simple task is ok though.

Can you suggest me anything to make this work?

So far, I tried to use
Code:
<?php include($_SERVER['DOCUMENT_ROOT']."/directory/stats_main.php"); ?>
but no luck.

Then, I create a file called "dir_stats.php" and write in it the code above. I called "dir_stats.php" in below code but still the same.

Anyone can help?


Below are my sidebar.php code.

Code:
<div id="side">
<ADSENSE>
</div>
<div class="sidebar1">

<h2 class="cat">xyTracker</h2>
<?php if (function_exists('useronline')): ?>
<ul><li><?php get_useronline(); ?></li></ul>
<?php endif; ?>
<?php if (function_exists('get_users_browsing_site')): ?>
<ul><li><?php get_users_browsing_site(); ?></li></ul>
<?php endif; ?>
<?php if (function_exists('get_users_browsing_page')): ?>
<ul><li><?php get_users_browsing_page(); ?></li></ul>
<?php endif; ?>



<h2 class="cat">xyCat</h2>
<ul>
<?php wp_list_cats(); ?>
</ul>
<h2 class="arc">xyArch</h2>
<ul>
<?php wp_get_archives('type=monthly'); ?>
</ul>

<h2 class="view" >Templates Demo</h2>
<div align="center" class="grp">
<?php include (TEMPLATEPATH . '/templates.php'); ?>
</div>

<h2 class="blogroll">xyNetwork</h2>
<ul>
<?php get_links('-1', '<li>', '</li>', '', FALSE, 'id', FALSE,
FALSE, -1, FALSE); ?>
</ul>
<h2 class="chain">xyLinks</h2>
<ul>
<?php include (TEMPLATEPATH . '/text_links.php'); ?>
</ul>

<h2 class="cat">xyDir Stats</h2>
<ul>
  <li>
    <?php include (TEMPLATEPATH . '/dir_stats.php'); ?>
  </li>
</ul>
 
<h2 class="meta">xyPanel</h2>
<ul>
<?php wp_register(); ?>
<li><?php wp_loginout(); ?></li>
<li><a href="http://www.xytheme.com/directory/">xytheMe Directory</a></li>
<li><a href="http://www.proxywhereabouts.com">Proxy Listing</a></li>
</ul>
</div>

<div class="sidebar2" align="center">
<ADSENSE>
<br>
<CANEP>

</div>
</div>
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable DomainsUnstoppable Domains
Can't you just hardcode it?

Possibly something like /home/you/public_html/directory/stats_main.php ?

Dan
 
0
•••
Dan,

How to insert that?
Is it like this?

Code:
<h2 class="cat">xyDir Stats</h2>
<ul>
  <li>
    <?php include (/home/you/public_html/directory/stats_main.php); ?>
  </li>
</ul>

I can't make this to work.

Thanks.
 
0
•••
PHP:
<?php
include('stats_main.php');
?>
should work, assuming you're main file is in the same directory as the calling file.
 
0
•••
If your file is located in a different directory try something like this if it's within your current working directory:

PHP:
<?php include('/dir/stats_main.php'); ?>

If it's above your current working directory use something like this (../ takes you back a directory, you can use this multiple times to go back multiple directories)

PHP:
<?php include('../../stats_main.php'); ?>

That is provided that your file is 2 directories back.

Finally you could try something like this if the file is a directory (or more) back but in another directory:

PHP:
<?php include('../other_dir/stats_main.php'); ?>

-RageD
 
0
•••
RageD said:
If your file is located in a different directory try something like this if it's within your current working directory:
PHP:
 <?php include('/dir/stats_main.php'); ?>
Will start at the beginning of the filesystem. To get to a directory above the current working directory you'd just have 'dir/stats_main.php' or './dir/stats_main.php'.
 
0
•••
My stats file is at this location:

Code:
public_html/directory/stats_main.php

My sidebar file located at:

Code:
public_html/wp-content/themes/mytheme/sidebar.php

So? is this how the code will looks like?

Code:
<?php include('../../../directory/stats_main.php'); ?>

[EDITED]

okay, that doesn't work.

I use this and it seems to get the file.

Code:
<h2 class="cat">xyDir Stats</h2>
<ul>
  <li>
    <?php include('/home/xytheme/public_html/directory/stats_main.php'); ?>
  </li>
</ul>

But, there is problem getting the file.

Code:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/xytheme/public_html/wp-content/themes/mytheme/header.php:5) in /home/xytheme/public_html/directory/stats_main.php on line 8

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/xytheme/public_html/wp-content/themes/mytheme/header.php:5) in /home/xytheme/public_html/directory/stats_main.php on line 8

Warning: Unexpected character in input: ''' (ASCII=39) state=1 in /home/xytheme/public_html/config.php on line 4

Parse error: syntax error, unexpected '<' in /home/xytheme/public_html/config.php on line 4
 
Last edited:
0
•••
It's getting the file fine, but there's a few problems with the code in stats_main.php and config.php. In the stats file, you have it starting a session. Sessions can only be started before any output is sent to the browser. To fix that problem, take session_start() from stats_main.php and put it at the beginning of your main file. You also have some parse errors in your config.php file. Parse errors are generally minor problems with how your code is structured.
 
0
•••
I can't just take it off from the file.
The file is actually a file from indexscript directory.

Seems like there is no way of doing this no?
 
0
•••
It's possible, you just have to edit the code a bit.
 
0
•••
I can't really see how your files are setup so this makes it a little more difficult to attack the problem unfortunately. What errors are you still receiving? (I mean have you made any changes since last post?)

-RageD
 
0
•••
i think just include method can resolve your problem
 
0
•••
Dynadot โ€” .com Registration $8.99Dynadot โ€” .com Registration $8.99
Appraise.net
Unstoppable Domains
Domain Recover
DomainEasy โ€” Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back