Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: include() does not work

  1. #1
    zikozeb is offline x10Hosting Member zikozeb is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    12

    Question include() does not work

    Hi

    I have simple website. The main structure is based on header, main content and footer as below:

    Code:
    <?php
        include($_SERVER['DOCUMENT_ROOT'.'/header.php');
    ?>
    <p>something here which contains main content</p>
    <?php
        include($_SERVER['DOCUMENT_ROOT'.'/footer.php');
    ?>
    Because I am going to use a couple of subscripts which are supposed to have the same header and footer I thought include woudl work perfect here. Unfortunately, the script is not run. It says include is not recognized text to parse. Is it something I am doing wrong or include simply does not exist? Is there any other way to make it work?

    Regards.

  2. #2
    Scoochi2's Avatar
    Scoochi2 is offline x10 Sophmore Scoochi2 is an unknown quantity at this point
    Join Date
    Aug 2008
    Location
    Southport!
    Posts
    185

    Re: include() does not work

    two ] are missing
    PHP Code:
    <?php
        
    include($_SERVER['DOCUMENT_ROOT'].'/header.php');
    ?>
    <p>something here which contains main content</p>
    <?php
        
    include($_SERVER['DOCUMENT_ROOT'].'/footer.php');
    ?>
    If anyone can see it, my post was meant for anyone who reads it. Don't take it personally or think I'm being condescending... :nuts:

  3. #3
    zikozeb is offline x10Hosting Member zikozeb is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    12

    Re: include() does not work

    Quote Originally Posted by Scoochi2 View Post
    two ] are missing
    PHP Code:
    <?php
        
    include($_SERVER['DOCUMENT_ROOT'].'/header.php');
    ?>
    <p>something here which contains main content</p>
    <?php
        
    include($_SERVER['DOCUMENT_ROOT'].'/footer.php');
    ?>
    Two of ']' <- this?

    Where? I cannot see that. Anyway, this is really not problem as syntax is incorrect. I have a impression that include is not a recognized function in version of PHP I am using.

  4. #4
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: include() does not work

    Quote Originally Posted by zikozeb View Post
    I have a impression that include is not a recognized function in version of PHP I am using.
    Which version, PHP 0.2 ?
    Seriously, you come across as someone who doesn't know what he is talking about.


    PHP Code:
    YOU:
    include(
    $_SERVER['DOCUMENT_ROOT'.'/header.php');
    CORRECT:
    include(
    $_SERVER['DOCUMENT_ROOT'].'/header.php'); 
    You really can't see the difference?
    Nothing is always absolutely so.

  5. #5
    zikozeb is offline x10Hosting Member zikozeb is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    12

    Re: include() does not work

    PHP Code:
    YOU:
    include(
    $_SERVER['DOCUMENT_ROOT'.'/header.php');
    CORRECT:
    include(
    $_SERVER['DOCUMENT_ROOT'].'/header.php'); 
    You really can't see the difference?
    Yes I can now. I have not seen that before. I wanted to appologize Scoochi2

    Scoochi2: The mistake was made because I have written this here from scratch and in my script everything's correct but it still does not work. So the main question is if function include() is working if I upload PHP script here?

    Quote Originally Posted by descalzo View Post
    Which version, PHP 0.2 ?
    Seriously, you come across as someone who doesn't know what he is talking about.
    Skip this this thread next time please, because if you really think I don't know what I am talking about only because I have not seen something in my code, I dont want you to participate with this discussion. You as programmer should know the most difficult is to find your own mistakes. I made just one mistake which I did not see and you have treated me like a total nOOb.

    Please just skip it next time, don't come here, don't judge me and say what I am.

    Please.

  6. #6
    xav0989's Avatar
    xav0989 is offline Community Public Relation xav0989 is just really nice
    Join Date
    Jul 2008
    Location
    ifk
    Posts
    4,438

    Re: include() does not work

    It's not that I don't enjoy watching internet flames war go on - it's quite funny from the sidelines - but I would ask that descalo don't comment on this and that zikozeb doesn't add anything, so that this doesn't become a hate post.

    Thanks. -if needed, a moderator could close this-
    Xavier L | Community Public Relations Manager (Free Hosting Support)
    █ Yes, my position is too cool to even exist!
    How am I helping? Rate this post by clicking the icon below! (this is even better than "liking" a post)
    Terms of Service | Acceptable Use Policy | x10Hosting Wiki

  7. #7
    Tariqul Islam's Avatar
    Tariqul Islam is offline x10 Sophmore Tariqul Islam is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    Bangladesh
    Posts
    182

    Re: include() does not work

    I can't figure out the main problem of this post.



  8. #8
    zikozeb is offline x10Hosting Member zikozeb is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    12

    Re: include() does not work

    It might not have stated clearly what was the main problem in this post. My english is not a first language and it's sometimes a reason i cannot precisely express my thoughts.

    My website will consist of 3 parts: header, footer and main content in the middle. I don't want to repeat in every script exactly those parts which are in header and footer. On my localhost I have used PHP function include(), which is supposed to add header and footer, in the similar way as below:
    PHP Code:
    <?php
        
    include($_SERVER['DOCUMENT_ROOT'].'/header.php');
    ?>
    <p>something here which contains main content</p>
    <?php
        
    include($_SERVER['DOCUMENT_ROOT'].'/footer.php');
    ?>
    The script works here at my localhost server. Once I have uploaded the example script with both functions include(), the server has showed information that in the line where this function is placed, there's a syntax error. As I was very surprised why, I have checked if this function exists at all. I have tied another script:
    PHP Code:
    if(function_exists('include')); 
    and it's returned false.

    My question is what I am doing wrong. Why I cannot include my header and footer. IS this due to limits on free hosting server?

    Thanks for any suggestions.

  9. #9
    Livewire's Avatar
    Livewire is offline Abuse Compliance Officer Livewire is a glorious beacon of lightLivewire is a glorious beacon of light
    Join Date
    Jun 2005
    Location
    Behind a keyboard.
    Posts
    8,998

    Re: include() does not work

    Quote Originally Posted by php.net Function_Exists Manual
    Note: This function will return FALSE for constructs, such as include_once() and echo().
    Include's a construct, not technically a function, so it'll return false although it exists.

    Other than that, I can't see why the code itself isn't working - it should be, but try just doing include("header.php"); and include("footer.php");


    Never really needed $_SERVER['document_root'] on my stuff on x10, although it's been a long while since I was doing it on a free server. Worth a shot to take it out though just to see if it works, since it isn't right now anyways


    TOS breakers will be suspended regardless of race, creed, national origin, hair color, or favorite food. Thanks for your understanding!

  10. #10
    Scoochi2's Avatar
    Scoochi2 is offline x10 Sophmore Scoochi2 is an unknown quantity at this point
    Join Date
    Aug 2008
    Location
    Southport!
    Posts
    185

    Re: include() does not work

    The code itself you have posted is fine and it should be working. Maybe there is a problem within either the header or footer pages.

    Can you post both of these in addition to the exact error message that appears when you try to run the page (copy paste it)?
    If anyone can see it, my post was meant for anyone who reads it. Don't take it personally or think I'm being condescending... :nuts:

Closed Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Jealous See
    By ichwar in forum Computers & Technology
    Replies: 216
    Last Post: 09-08-2009, 09:59 AM
  2. Prison vs Work
    By John Klyne in forum Off Topic
    Replies: 10
    Last Post: 12-21-2008, 01:44 PM
  3. Php scripts don't work
    By Slicker in forum Free Hosting
    Replies: 4
    Last Post: 11-16-2008, 08:03 AM
  4. Alot Of Your Portals Dont Work
    By harmonixx in forum Free Hosting
    Replies: 1
    Last Post: 04-03-2008, 06:14 AM
  5. links dont work
    By Jake Bullet in forum Free Hosting
    Replies: 1
    Last Post: 09-13-2005, 03:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers