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 7 of 7
  1. #1
    New Coder
    Join Date
    Jan 2005
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP include no longer works?

    A while back, I used to use the:

    <?php include("$id.html"); ?>

    for my site, but then I stopped for a while. Now, I come back to use it, and it doesn't work.

    I put this "<?php include("$id.html"); ?>" where my content normally goes in "main.php" and then I go to "site.com/main.php?id=content" (where content is an HTML), but I get an error that says:

    Code:
    Warning: main(.html) [function.main]: failed to open stream: No such file or directory in /home/animegal/public_html/nosuchthing/newlayout/main.php on line 74
    
    Warning: main(.html) [function.main]: failed to open stream: No such file or directory in /home/animegal/public_html/nosuchthing/newlayout/main.php on line 74
    
    Warning: main() [function.include]: Failed opening '.html' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/animegal/public_html/nosuchthing/newlayout/main.php on line 74
    am I doing something wrong? this used to work - that's why I think that it's me doing something wrong...

    Any suggestions?

  • #2
    Regular Coder croatiankid's Avatar
    Join Date
    Jan 2006
    Posts
    665
    Thanks
    1
    Thanked 12 Times in 12 Posts
    get rid of the $, they're only for variables.

  • #3
    New Coder
    Join Date
    Jan 2005
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You mean out of the original code? So it would be:

    <?php include("id.html"); ?>

    that didn't work

  • #4
    New Coder
    Join Date
    Dec 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Couldn't you use fopen?

    As in:
    PHP Code:
    <?php
    $fname 
    "id.html";
    $fr fopen($fname'r');
    $Result fread($frfilesize($fname));
    fclose($fr);
    echo 
    $Result;
    ?>
    Keep the $ if it's inside a string and the filename has it.

  • #5
    New Coder
    Join Date
    Jan 2005
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts
    do I need to change something in that code, or just paste it where I need the content to show up?

  • #6
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,055
    Thanks
    10
    Thanked 94 Times in 92 Posts
    looks like register_globals has been turned off... use
    PHP Code:
    <?php include("{$_GET['id']}.html"); ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #7
    New Coder
    Join Date
    Jan 2005
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Great! That worked!

    Thanks


  •  

    Posting Permissions

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