Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
incuding 1 file among 2 file?
Old 01-21-2010, 12:02 PM incuding 1 file among 2 file?
Average Talker

Posts: 24
Trades: 0
I do apologize for asking this stupid question but I am wondering if you can help me..

i want insert among file $cat1 or $cat2 to in page.php...
the code i was create e.g.
PHP Code:
<? //config.php
$cat_all = ($cat2 or $cat1);
$cat1 "cat.php" ;
$cat2 "../back-up/cat.php"//default anyway
if(file_exists($cat1)){
    require_once 
$cat1;
}else{
    require_once 
$cat2;
}
?>

<? //page.php
require "config.php";
function 
ShowIndexProd($number){
    
$ar file($cat_all); // <------- input here //
    
$sizear count($ar)-$number;
    
$data explode("#",$ar[$sizear]);
    echo 
"
    <td class='BoxIndex' width='30%'><a href='prod_show.php?id=
$sizear'><IMG SRC='img/$data[5]' width=150 border=0></a> <BR /><BR />
        <B><FONT COLOR='red'> 
$deti[2] </FONT></B> <BR />
        <B>Price:</B>
$rp $data[3] $usd<BR />
        <a href='prodshow.php?id=
$sizear'><b><FONT COLOR='#FF6600'> more details... </FONT></b></a>
    </td>"
;
}
but the result: file $cat1 or $cat2 printed to html page, that i want them as file configuration..
any help would much appreciate and thank you
jones is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-22-2010, 10:58 AM Re: incuding 1 file among 2 file?
Novice Talker

Posts: 8
Name: robert
Trades: 0
I would help but would need you to explain a bit more as to what your trying to achieve..
greatness is offline
Reply With Quote
View Public Profile
 
Old 01-22-2010, 02:53 PM Re: incuding 1 file among 2 file?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Don't use relative path to your include, but an absolute, and you'll be ok
PHP Code:
require_once($_SERVER['DOCUMENT_ROOT']."/cat.php"); 
This will ensure that you always require() the file in the root folder of your site.

And if you want to include another file if it exists or fall back on the one in the root folder:
PHP Code:
$file=$_SERVER['DOCUMENT_ROOT']."/cat.php";
if(
is_file($_SERVER['DOCUMENT_ROOT']."/back-up/cat.php")===true){
  
//if the file back-up/cat.php exists only
  
$file=$_SERVER['DOCUMENT_ROOT']."/back-up/cat.php";
}
require_once(
$file); 
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to incuding 1 file among 2 file?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.47372 seconds with 12 queries