including-1-file-among-2-file

Discussion in 'PHP' started by s.jns, Jan 21, 2010.

  1. #1
    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.

    <? //config.php
    $cat_all = ($cat2 or $cat1); //<-----//
    $cat1 = "cat.php" ;
    $cat2 = "../back-up/cat.php"; //default
    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>";
    }
    PHP:
    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
     
    s.jns, Jan 21, 2010 IP
  2. bitist

    bitist Peon

    Messages:
    28
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Your question is not too clear.
    Also the code you pasted have some errors.
    $cat_all = ($cat2 or $cat1); //<-----//
    $cat1 = "cat.php" ;
    $cat2 = "../back-up/cat.php"; //default
    PHP:
    You try to "$cat2 or $cat1" but they are not initialized at that position....
     
    bitist, Jan 21, 2010 IP
  3. RDJLabs

    RDJLabs Peon

    Messages:
    170
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I dont t hink

    $cat_all = ($cat2 or $cat1); this is gonna work

    because you have || instead of or in php

    Try changing this
     
    RDJLabs, Jan 22, 2010 IP
  4. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #4
    "||" and "or" work identically in that line.

    They are both wrong, though, as the code makes no sense that way. However, I can't even begin to answer the question, because the way it was written makes no sense, and the rest of the code makes very little sense as well.

    Perhaps s.jns would care to come back and explain in English what he is trying to do.
     
    SmallPotatoes, Jan 22, 2010 IP