Results 1 to 6 of 6

Thread: require error...

  1. #1
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default require error...

    I am having a problem with the php require function. With this piece of code:
    PHP Code:
        if(isset($_GET['upload'])){
        require(
    "../forms/upload_pictures.php?number=" $_GET['upload']);
        } 
    Now I get this error
    Code:
    Warning: require(../forms/upload_pictures.php?number=5) [function.require]: failed to open stream: No error in C:\wamp\www\getaband.net\phpbin\edit_pictures_musician.php on line 23
    
    Fatal error: require() [function.require]: Failed opening required '../forms/upload_pictures.php?number=5' (include_path='.;C:\php5\pear') in C:\wamp\www\getaband.net\phpbin\edit_pictures_musician.php on line 23
    I have checked the link and it is the page I'm trying to reach because when I take the get variable part out ?number=" . $_GET['upload'] then it loads the page...

    If someone could help me through this that would be great, thanks!

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    When you require or include a local file, it's imported into the current script as if it had been copied and pasted. You can't send a GET variable, since it isn't accessed via HTTP. Instead, you can pass it as a variable, or modify the $_GET array so that the included page will see the modified version.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    I don't think I understand but I'll speak what I thought you said...

    So instead of using $_Get['number']; Use $number?

    Is that right?

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    That'll do, yes. The included page has access to all global variables in the including page.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Actually, it shouldn't matter. The GET variable is global on the first page, and will also be global on the second. So, you're fine-- just include/require the page as you normally would and do NOT at the ?.... part.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    now i'm confused...
    So instead of doing this:
    PHP Code:
    require("cantrememberurl.php?number=" $_GET['number']); 
    I should do this
    PHP Code:
    require($url); 
    And have $url be:
    PHP Code:
    cantrememberurl.php?number=" . $_GET['number'] 
    Otherwise I have not a clue

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
  •