Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    mjs
    mjs is offline
    New Coder
    Join Date
    Jan 2010
    Posts
    97
    Thanks
    17
    Thanked 0 Times in 0 Posts

    including file ??, please help

    I am new to php without any knowledge and degree or course class so
    I do apologize for asking this stupid question but I am wondering if you can help me..

    i want insert 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'> $data[2] </FONT></B> <BR />
            <B>Price:</B>$rp $data[3] $usd<BR />
            <a href='prod_show.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
    Last edited by mjs; 01-22-2010 at 08:22 AM.

  • #2
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    is config.php and page.php two different files and you posted them together?
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?

  • #3
    mjs
    mjs is offline
    New Coder
    Join Date
    Jan 2010
    Posts
    97
    Thanks
    17
    Thanked 0 Times in 0 Posts
    the config.php and page.php are two different files and i posted them in different direcotry ?
    i.e.

    file & directory structures:

    Code:
    localhost/mysite/config/config.php
    
    localhost/mysite/prod/page.php
    
    localhost/mysite/db/cat.php //as $cat1
    
    localhost/mysite/back-up/cat.php //as $cat2

  • #4
    mjs
    mjs is offline
    New Coder
    Join Date
    Jan 2010
    Posts
    97
    Thanks
    17
    Thanked 0 Times in 0 Posts
    anyone else could help me, please?

  • #5
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    Just took a quick glance, and you have several problems.

    1. This line will return a boolean value (true or false):
    PHP Code:
    $cat_all = ($cat2 or $cat1); 
    which is not what you are expecting.

    2. You then use $cat_all inside of a function, but at that point the value is out of scope since you did not define it inside the function
    John

  • #6
    mjs
    mjs is offline
    New Coder
    Join Date
    Jan 2010
    Posts
    97
    Thanks
    17
    Thanked 0 Times in 0 Posts
    Hi, PappaJohn i welcome you.

    but i bit don't understand your input... what the meaning
    value is out of scope since you did not define it inside the function
    would you give the samples code?

    Blessing upon You..

  • #7
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by mjs View Post
    Hi, PappaJohn i welcome you.

    but i bit don't understand your input... what the meaning

    would you give the samples code?

    Blessing upon You..
    PHP Code:
    function myfunc(){
       
    $myvar 'a variable inside a function, local scope: myfunc';
    }

    echo 
    $myvar// this is undefined because is local in myfunc 
    best regards

  • #8
    mjs
    mjs is offline
    New Coder
    Join Date
    Jan 2010
    Posts
    97
    Thanks
    17
    Thanked 0 Times in 0 Posts
    i think this question need to be hold for a moment... now i know what the problem

    @$cat2 @$cat1, prior as .txt file then i change it become .php without put tags <? ?>.

    the inside of file @$cat2 @$cat1 e.g.
    -Properties
    -Cars
    -Animals
    -Etc...

    all as Categori

    then when i add the tag <? ?>, it's goes to ought, but now i face that tag <? ?> also printed at the categori...


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •