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 10 of 10

Thread: include problem

  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    905
    Thanks
    23
    Thanked 5 Times in 5 Posts

    include problem

    afternoon

    problem with a include.. code as follows ...
    It looks for a file called "directory_content.php?genre=$bygenre&letter=$byletter" ... it doesnt stop at the question mark, I have tried enclosing it in ' ' and also not at all but no luck..

    PHP Code:
    <? include "directory_content.php?genre=$bygenre&letter=$byletter"?>
    Anyone know why it does not end the file name before the question mark? It just says file not found message, as there is no file called directory_content.php?genre=$bygenre&letter=$byletter.. obviously diectory_content.php is there.

    cheers
    P

  • #2
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You should be doing something like this instead:
    Code:
    <?php
    
    $_GET['genre']  = $bygenre;
    $_GET['letter'] = $byletter;
    include "directory_content.php";
    
    ?>

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    905
    Thanks
    23
    Thanked 5 Times in 5 Posts
    Hi fci,

    Thanks for your reply.
    Yeah I guess the safe/proper way to be to get the variables like that, somtimes I'm terribly lazy :$ ... though that is not what is causing the problem here. For example, I have changed the include file to just "directory_content.php?" and it thinks the question mark is part of the file name, and cannot find that file as it is not there.

    I have corrected the variable laziness now too. But yeh thats the problems, any thoughts?

    strange one.

  • #4
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It looks for a file called "directory_content.php?genre=$bygenre&letter=$byletter" ... it doesnt stop at the question mark,
    Anyone know why it does not end the file name before the question mark?
    I don't get it. Why would it stop at the question mark when there is a query string after it?

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Posts
    905
    Thanks
    23
    Thanked 5 Times in 5 Posts
    it would not stop, though would usally only reconise the file name as the part before the question mark, same as a href .. file.php?stuff=whatever .. that would load file.php and put stuff=whatever after the filename.. usually.. what? lol

  • #6
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    the ? is only part of the query string in HTTP
    when you `include 'file.php`' you are in fact doing

    include '/your/document_root/file.php';
    or
    include '/your/include/path/file.php';

    those are filepaths not urls so the ? is taken literally and PHP is looking for the non existant file 'file.php?'

    Apache knows that the '?' is the start of the query string and parses it as such , so include http;//your_domain.com/file.php?g=a would work but the code would be parsed by apache before it gets to your script.
    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
    Regular Coder
    Join Date
    Jun 2002
    Posts
    905
    Thanks
    23
    Thanked 5 Times in 5 Posts
    Firepages .. you will like this ...

    I could not get my head round it .. and reading what you wrote still did not make sense... I could have SWORN I had done this exact thing before.
    And then it dawned on me... OF COURSE it would not be able to deal with the question mark.. its not HTTP...I have spent the last week working on IFRAMEs for a project I had ...
    Man includes are so much simpler as they can pick the vars up from their parent page.. there is no need to question mark and query after the file name!

    What was I thinking!! Haha, good times.

    Cheers for your time everyone
    A very ashamed, Sir P.

  • #8
    New to the CF scene
    Join Date
    Feb 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    include solved

    hi,

    use this code for the include file
    include "hme.php?id=".$preid;

  • #9
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by srinivasm2006
    hi,

    use this code for the include file
    include "hme.php?id=".$preid;
    I'd recommend reading the thread before replying next time.

  • #10
    Regular Coder
    Join Date
    Jun 2002
    Posts
    905
    Thanks
    23
    Thanked 5 Times in 5 Posts
    owned :$


  •  

    Posting Permissions

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