SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2007
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Include: Can you look at this for me please?

    Hello there.

    I just wrote the most minimal PHP I could figure out to see if anything connected with anything. I am not on a server; I am trying to do this inside my Windows machine.

    My HTML (it has a php suffix, and which works fine otherwise) contains

    Code:
    <div id="kielbasa">
    Anybody home?
    <?php include "/includes/menu.php";?>
    </div>  <!--end kielbasa-->
    and in the folder where all the html and php stuff is, there's a folder called "includes". In that folder is just a little text

    Code:
    <p>
    anything I try
    </p>
    "Anybody home?" is just to see whether the div is working and in place (it is). I can't figure out how to connect the php to display anything after that though. The fellow who got me this far gave me some fancy server language but I stripped it down to what the kiddie pages say to do, to try to get at the basics of what's happening.

    There's something I'm not understanding here. Would you like to give me a hand? Sorry if what I'm asking doesn't make sense. I don't know enough to make sense.

    Thanks

    MP

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,227
    Mentioned
    194 Post(s)
    Tagged
    2 Thread(s)
    I'm not clear as to what or how you're doing things.

    All the paths to the files and file name spelling is correct.
    You start up your localhost PHP server.
    But when you open the "anybody home" file in your browser "anything I try" doesn't show?

  3. #3
    SitePoint Wizard Ren's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    1,060
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Remove the first / from the path.

    <?php include "includes/menu.php";?>

  4. #4
    SitePoint Enthusiast
    Join Date
    Jan 2007
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But when you open the "anybody home" file in your browser "anything I try" doesn't show?

    Yep.

    Remove the first / from the path.

    Nope.

    I picked up the Dummies book and it says to write in the whole path to the inclusion starting with c: That didn't change anything. In some of their examples they put the path in parentheses and in some of them they don't so I tried parentheses. That didn't change anything.

    BUT....

    You start up your localhost PHP server.

    Uh....the WAMP has to be running even though everything's happening inside one folder and one subfolder? Well, I fired that up. Still nada.

    Tried renaming the "includes" folder to "include", because the book said that if I did that I wouldn't need any path at all, just the file name. Uh-Uh.

    Tried copying the file into the folder right in with all the html stuff. Nope.

    Now I'm wondering whether the inclusion and the "include" folder is supposed to be stored in some special other place having something to do with WAMP? I mean, even just for while I'm messing around trying to write this thing?

    ???

    MP

  5. #5
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    What happens when you put these addresses in your browser:

    http://127.0.0.1

    http://localhost

  6. #6
    SitePoint Enthusiast
    Join Date
    Jan 2007
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In both cases they take me to a WAMP Server Configuration page, showing Apache, PHP, and MySQL versions. I doubt that they're old; I'm just starting to mess with this stuff.

    Thanks

    p

  7. #7
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Well, the file being served from localhost (or 127.0.0.1 if you prefer) is the root of your webserver. No doubt it is called index.php. You need to find out where that folder is located on your file system.

    Remove or rename that file, then create a new index.php file.

    Temporarily create a folder in there too, /includes and then try your experiment again.

  8. #8
    SitePoint Enthusiast
    Join Date
    Jan 2007
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope.

    I did find it, I did set it aside and put in a copy of the "menu.php" file in that folder. No go.

    I put a folder called "include" and "includes" in that folder and that didn't play either. I copied that folder up a level, even with WAMP's www folder and that didn't work either.

    I might be getting to where I have to ship this to one of you guys and pay you to fix it....Apparently other people just do this and it works, and I can't.

    MP

  9. #9
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    You'll get nowhere with this if you do not get to the bottom of the problem.

    index.php
    PHP Code:
    <?php


    echo '<p>This is the index file</p>';

    include 
    './menu.php';


    ?>
    menu.php
    PHP Code:
    <?php
    echo '<p>This is my menu</p>';
    ?>
    Put them both in your web root directory and see if that works when you load index.php

  10. #10
    SitePoint Enthusiast
    Join Date
    Jan 2007
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ooh, I got it.

    Thanks, Cups. I won't detail what I was doing wrong, because it was profoundly dumb and although I'm accustomed to that, sometimes other people aren't.

    Thanks so much.

    Mp

  11. #11
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    No, we all felt exactly the same level of dumbness at some time or another (usually still on a daily basis) so don't worry ... you're in good company.


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
  •