Reply
Need help with calling a file. - php include
Old 04-04-2008, 06:59 PM Need help with calling a file. - php include
nyunyu's Avatar
Super Talker

Posts: 111
Name: Aizal
Hi web gurus!

I need a small favor to ask.

Here is my problem.

Okay, I got a blog/template site at www.xytheme.com
And I also install a web directory on it at www.xytheme.com/directory

On the directory, you can see that I called the stats and put it on the main site. I named it as stats_main.php

I then want to call the file again on my blog, to add it onto my sidebar. I tried to call it but no luck. I guess I did it wrong. I call it as
Code:
<?php include (".../directory/dir_stats.php"); ?>
Here is the file tree:

Code:
stats file resides at: home/public_html/dir/stats_main.php
wordpress theme resides at: home/public_html/wp-content/themes/mytheme/
Can you help me with this?
nyunyu is offline
Reply With Quote
View Public Profile Visit nyunyu's homepage!
 
When You Register, These Ads Go Away!
     
Old 04-04-2008, 07:08 PM Re: Need help with calling a file. - php include
tripy's Avatar
Fetchez la vache!

Posts: 1,924
Name: Thierry
Location: In the void
... is not a valid path part.
You have:
Code:
.    the current directory
..   one directory up
/    the top directory
The better approach (in my opinion) is to use the $_SERVER['DOCUMENT_ROOT'] value, like this (I assume that the web site document root is home/public_html. You may need to fidle with this if it's not the case.
PHP Code:
include($_SERVER['DOCUMENT_ROOT']."/dir/stats_main.php"); 
__________________
Listen to the ducky: "This is awesome!!!"

tripy is offline
Reply With Quote
View Public Profile
 
Old 04-04-2008, 07:21 PM Re: Need help with calling a file. - php include
nyunyu's Avatar
Super Talker

Posts: 111
Name: Aizal
I put the code like this

Code:
<h2 class="cat">xyDir Stats</h2>
<ul>
  <li>
    <?php include($_SERVER['DOCUMENT_ROOT']."/directory/stats_main.php"); ?>
  </li>
</ul>
And it gave an error like this:

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/acosminv2/header.php:5) in /home/xytheme/public_html/directory/stats_main.php on line 8
nyunyu is offline
Reply With Quote
View Public Profile Visit nyunyu's homepage!
 
Old 04-04-2008, 07:43 PM Re: Need help with calling a file. - php include
tripy's Avatar
Fetchez la vache!

Posts: 1,924
Name: Thierry
Location: In the void
it's because your file makes a session_start(), and it should be called before any html.
You have to move the include on the top of the first included file.
__________________
Listen to the ducky: "This is awesome!!!"

tripy is offline
Reply With Quote
View Public Profile
 
Old 04-05-2008, 06:08 AM Re: Need help with calling a file. - php include
nyunyu's Avatar
Super Talker

Posts: 111
Name: Aizal
Below are my sidebar.php code.
As you can see from www.xytheme.com, there is a sidebar there and I want to put my directory stats there.

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, 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?



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>
nyunyu is offline
Reply With Quote
View Public Profile Visit nyunyu's homepage!
 
Old 04-05-2008, 03:12 PM Re: Need help with calling a file. - php include
nyunyu's Avatar
Super Talker

Posts: 111
Name: Aizal
help me please, I still don't have an idea of how to achieve this.
nyunyu is offline
Reply With Quote
View Public Profile Visit nyunyu's homepage!
 
Reply     « Reply to Need help with calling a file. - php include
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13506 seconds with 13 queries