SitePoint Sponsor

User Tag List

Results 1 to 11 of 11

Thread: $_GET function?

  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $_GET function?

    test.php contains:
    $keyword = $_GET['keyword'];
    echo $keyword;

    http://www.mysite.com/test.php?keyword=money


    I'm using a relative path, so it doesnt work (Doesnt echo the keyword). If i use a remote path path, it works. But i would like to use a relative path, so how would i fix it?

  2. #2
    SitePoint Guru enygmadae's Avatar
    Join Date
    Sep 2002
    Location
    Dallas, Tx.
    Posts
    795
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Um, there shouldn't be any difference on there at all...$_GET works no matter what
    PHP News, Views and Community: http://www.phpdeveloper.org

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yup it should but it doesnt work. maybe it's because it only works on URLs? cause when i use relative path, the path is just /home/username/public_html/test.php?keyword=money

    if i call that file using remote path path (tested already), it works.

  4. #4
    Keep it simple, stupid! bokehman's Avatar
    Join Date
    Jul 2005
    Posts
    1,933
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sigh... You can't use a query string on a server path.

  5. #5
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what's a query string? if i cant use that, what can i use?

  6. #6
    Keep it simple, stupid! bokehman's Avatar
    Join Date
    Jul 2005
    Posts
    1,933
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This: ?keyword=money cannot be used with a server path.

  7. #7
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is there something else i can use besides that? i would like to grab the keyword somehow but must use relative path

  8. #8
    Keep it simple, stupid! bokehman's Avatar
    Join Date
    Jul 2005
    Posts
    1,933
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you post the surrounding code? Probably just use a variable.

  9. #9
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i have two files: a.php and test.php.

    a.php contains:

    PHP Code:
    <?php
    include("$DOCUMENT_ROOT/test.php?keyword=money");
    ?>
    test.php contains
    PHP Code:
    <?php
    $keyword 
    $_GET['keyword'];
    echo 
    $keyword;
    ?>
    i havent done much yet, cause im still stuck at getting the "keyword" part. I was thinking of maybe write to a file in a.php and then read it from test.php. would that work? or is there an easier way?

  10. #10
    Keep it simple, stupid! bokehman's Avatar
    Join Date
    Jul 2005
    Posts
    1,933
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    a.php:
    PHP Code:
    <?php
    $keyword 
    'something';
    include(
    $_SERVER['DOCUMENT_ROOT'].'/test.php');
    ?>
    test.php:
    PHP Code:
    <?php
    echo $keyword;
    ?>

  11. #11
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    awesome that worked, thanks alot


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
  •