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 2 of 2
  1. #1
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,092
    Thanks
    26
    Thanked 0 Times in 0 Posts

    Problems with Query String

    I'm having several interrelated issues with my Query String and PHP script.

    Here is a sample URL that I am working on...

    http://local.debbie/account/view-pm/incoming/


    And here is my PHP code...
    PHP Code:
        if (isset($_GET['msgview']) && $_GET['msgview']){
            
    // Message-View found in URL.

            // Set Case.
            
    $msgView strtolower($_GET['msgview']);
            echo 
    $msgView "<br />"

    When I load the URL above, my test script echoes this...
    incoming/

    Shouldn't my $_GET just be grabbing "incoming" and not the trailing slash?


    Debbie

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,323
    Thanks
    60
    Thanked 525 Times in 512 Posts
    Blog Entries
    4
    Run it through basename() which will return just the name.

    http://php.net/manual/en/function.basename.php



    Example #1 basename() example
    <?php
    echo "1) ".basename("/etc/sudoers.d", ".d").PHP_EOL;
    echo "2) ".basename("/etc/passwd").PHP_EOL;
    echo "3) ".basename("/etc/").PHP_EOL;
    echo "4) ".basename(".").PHP_EOL;
    echo "5) ".basename("/");
    ?>

    The above example will output:

    1) sudoers
    2) passwd
    3) etc
    4) .
    5)
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

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