SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Sep 2005
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Small If Statement help

    Hi all

    Searched all over the place but just can't get this to work. I think I have followed what I have found on the web but it just aint working. Any assistance would be gratefully received.

    If the field says yes i want to display a file if not then i dont want it to do anything.

    Thisd is what I have done:


    PHP Code:
    if ($activity == "rec"){
        echo 
    "filename.php<br />";
    } else {
        echo 
    "";

    I also tried include('filename.php') but that didnt work either

    Please help, its driving me nuts

    Thanks

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2006
    Location
    Wigan, Lancashire. UK
    Posts
    523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if ($activity == "rec"){
        echo 
    file_get_contents("filename.php");
    } else {
        echo 
    "";

    ---
    Development Projects:
    PHPExcel
    PHPPowerPoint

  3. #3
    SitePoint Evangelist ferrari_chris's Avatar
    Join Date
    Mar 2008
    Location
    NP, New Zealand
    Posts
    576
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if ($activity == "rec"){
        include 
    "filename.php";


  4. #4
    SitePoint Zealot
    Join Date
    Sep 2005
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for that, cant beleive i was so close yet so bloody far away

    Can I also do this?


    PHP Code:
    if ($activity == "rec"){

        include 
    "/home/sites/mydomain.com/public_html/directoryname/filename.php";


    and can I include a file outside of the root directory?

    Once again Many Thanks

  5. #5
    SitePoint Wizard Young Twig's Avatar
    Join Date
    Dec 2003
    Location
    Albany, New York
    Posts
    1,355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by QuizToon View Post
    Thanks for that, cant beleive i was so close yet so bloody far away

    Can I also do this?


    PHP Code:
    if ($activity == "rec"){

        include 
    "/home/sites/mydomain.com/public_html/directoryname/filename.php";


    and can I include a file outside of the root directory?

    Once again Many Thanks
    That should work, yes.

    You can include any file on your server that is within the open_basedir setting (if any exists). Depending on your server setup, you can probably access anything inside of /home/sites/mydomain.com.

  6. #6
    SitePoint Enthusiast
    Join Date
    Oct 2008
    Location
    Spain
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by QuizToon View Post
    and can I include a file outside of the root directory?
    You can include any file as long as you have read permissions for that file
    Link Exchange system - Submit your website/s and exchange links
    Aprende a programar - Conceptos básicos sobre programación
    Estadísticas de bolsa - Resultados en los índices bursátiles

  7. #7
    SitePoint Wizard Young Twig's Avatar
    Join Date
    Dec 2003
    Location
    Albany, New York
    Posts
    1,355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rewy View Post
    You can include any file as long as you have read permissions for that file
    Right, you'll need those too.

  8. #8
    SitePoint Zealot
    Join Date
    Sep 2005
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great stuff

    Thanks a lot everyone

    Once again Sitepoint comes to the rescue



Bookmarks

Posting Permissions

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