[advanced search]
NamePros Domain Auction
Live Event This Thursday at 6PM EDT - Prebidding open now
23 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Domain Name Industry Newsletter
Go Back   NamePros.Com > Design and Development > Programming
User Name
Password

Old 04-05-2008, 04:53 PM   · #1
nyunyu
NamePros Member
 
Name: Aizal a.k.a Ice
Location: Malaysia
Trader Rating: (1)
Join Date: Dec 2007
Posts: 47
NP$: 0.00 (Donate)
nyunyu is on a distinguished road
Thumbs down Need help with calling a file. - php include

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>


Please register or log-in into NamePros to hide ads
nyunyu is offline   Reply With Quote
Old 04-06-2008, 09:59 AM   · #2
Daniel
Danltn.com
 
Daniel's Avatar
 
Name: Daniel Neville
Location: Danltn.com / Nottingham, UK
Trader Rating: (65)
Join Date: May 2007
Posts: 1,185
NP$: 0.56 (Donate)
Daniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond repute
Ethan Allen Fund Ethan Allen Fund
Can't you just hardcode it?

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

Dan
Daniel is offline   Reply With Quote
Old 04-06-2008, 05:12 PM   · #3
nyunyu
NamePros Member
 
Name: Aizal a.k.a Ice
Location: Malaysia
Trader Rating: (1)
Join Date: Dec 2007
Posts: 47
NP$: 0.00 (Donate)
nyunyu is on a distinguished road
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.
nyunyu is offline   Reply With Quote
Old 04-06-2008, 06:57 PM   · #4
Tree
NamePros Regular
 
Tree's Avatar
 
Name: Trevor
Location: Atlanta, GA, USA
Trader Rating: (3)
Join Date: Feb 2006
Posts: 334
NP$: 0.00 (Donate)
Tree will become famous soon enoughTree will become famous soon enough
PHP Code:
<?php
include('stats_main.php');
?>
should work, assuming you're main file is in the same directory as the calling file.
__________________
NCIDev.com
Tree is offline   Reply With Quote
Old 04-06-2008, 08:01 PM   · #5
RageD
Senior Member
 
Name: Dennis
Location: Joliet, Illinois
Trader Rating: (43)
Join Date: Apr 2005
Posts: 1,149
NP$: 349.10 (Donate)
RageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to behold
Child Abuse
If your file is located in a different directory try something like this if it's within your current working directory:

PHP Code:
<?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 Code:
<?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 Code:
<?php include('../other_dir/stats_main.php'); ?>


-RageD
RageD is offline   Reply With Quote
Old 04-06-2008, 09:40 PM   · #6
Tree
NamePros Regular
 
Tree's Avatar
 
Name: Trevor
Location: Atlanta, GA, USA
Trader Rating: (3)
Join Date: Feb 2006
Posts: 334
NP$: 0.00 (Donate)
Tree will become famous soon enoughTree will become famous soon enough
Originally Posted by RageD
If your file is located in a different directory try something like this if it's within your current working directory:
PHP Code:
<?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'.
__________________
NCIDev.com
Tree is offline   Reply With Quote
Old 04-07-2008, 03:08 AM   · #7
nyunyu
NamePros Member
 
Name: Aizal a.k.a Ice
Location: Malaysia
Trader Rating: (1)
Join Date: Dec 2007
Posts: 47
NP$: 0.00 (Donate)
nyunyu is on a distinguished road
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 by nyunyu : 04-07-2008 at 03:27 AM.
nyunyu is offline   Reply With Quote
Old 04-07-2008, 07:35 AM   · #8
Tree
NamePros Regular
 
Tree's Avatar
 
Name: Trevor
Location: Atlanta, GA, USA
Trader Rating: (3)
Join Date: Feb 2006
Posts: 334
NP$: 0.00 (Donate)
Tree will become famous soon enoughTree will become famous soon enough
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.
__________________
NCIDev.com
Tree is offline   Reply With Quote
Old 04-07-2008, 08:33 AM   · #9
nyunyu
NamePros Member
 
Name: Aizal a.k.a Ice
Location: Malaysia
Trader Rating: (1)
Join Date: Dec 2007
Posts: 47
NP$: 0.00 (Donate)
nyunyu is on a distinguished road
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?
nyunyu is offline   Reply With Quote
Old 04-07-2008, 09:48 AM   · #10
Tree
NamePros Regular
 
Tree's Avatar
 
Name: Trevor
Location: Atlanta, GA, USA
Trader Rating: (3)
Join Date: Feb 2006
Posts: 334
NP$: 0.00 (Donate)
Tree will become famous soon enoughTree will become famous soon enough
It's possible, you just have to edit the code a bit.
__________________
NCIDev.com
Tree is offline   Reply With Quote
Old 04-07-2008, 02:48 PM   · #11
RageD
Senior Member
 
Name: Dennis
Location: Joliet, Illinois
Trader Rating: (43)
Join Date: Apr 2005
Posts: 1,149
NP$: 349.10 (Donate)
RageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to behold
Child Abuse
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
RageD is offline   Reply With Quote
Old 04-08-2008, 02:12 AM   · #12
comsit
New Member
 
Name: Shahzad
Location: pk
Trader Rating: (0)
Join Date: Mar 2008
Posts: 4
NP$: 0.00 (Donate)
comsit is an unknown quantity at this point
i think just include method can resolve your problem
__________________
unlock your cell phone know
comsit is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

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
Forum Jump


Site Sponsors
http://www.mobisitetrader.com/ YUPPADS http://www.mobisitetrader.com/
Advertise your business at NamePros
All times are GMT -7. The time now is 08:22 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0