SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Oct 2002
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php include() error...possible php.ini edit needed?

    Here's the code I'm using:
    PHP Code:
    <?php include ("$id.php"); ?>
    This should allow me to to maintain a constant layout of my site by using an url like this: http://mysite.com/main.php?id=content

    However, I'm getting a nice size error that reads as follows:

    Notice: Undefined variable: id in c:\inetpub\wwwroot\main.php on line 124

    Warning: main(.php) [function.main]: failed to create stream: No such file or directory in c:\inetpub\wwwroot\include.php on line 124

    Warning: main() [function.main]: Failed opening '.php' for inclusion (include_path='.;c:\php4\pear') in c:\inetpub\wwwroot\include.php on line 124

    I've never seen this error before and I'm making a guess that I need to edit something in my php.ini file somewhere?

  2. #2
    Resistance is Futile webgodjj's Avatar
    Join Date
    Nov 2002
    Location
    Madison, WI USA
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is the page you are tring to include id.php? if so, drop the $ sign.

  3. #3
    SitePoint Member
    Join Date
    Oct 2002
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no, I know how to include specific files like that. I've been reading recently how you can use include() on the main layout of the page and then call the other pages you are wanting to include. i.e. I can use include($id.php) once on my main site and then have all my links for content be simply /main.php?id=content, where content.php is a separate file. I could do the same thing by changing the url to main.php?id=links and have it call the file links.php
    By using the include() for a specific page I would have to put that on every page so that it includes my main layout. Is that understandable? Let me know if you don't get what I'm saying

  4. #4
    SitePoint Member
    Join Date
    Oct 2002
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php include ("$_GET[id].php"); ?>
    I ended up using this and it worked. However, being fairly new to php I don't understand how you can use $_GET[] in this instance...

  5. #5
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Using this, you are INCLUDEing the file given by the variable ID.

    Remember it's the content and not the actual variable it's self ?

  6. #6
    SitePoint Member
    Join Date
    Oct 2002
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah, I forgot that $_GET[] passed stuff into the url


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
  •