WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Problems with $_GET (4 posts)

  1. bnvt
    Member
    Posted 3 years ago #

    HI!

    I'm rather new to WP, but have been successful so far developing a complex blog with the help of the documentation and forums. But...

    I'm trying to implement some functionality using php $_GET, and it doesn`t work. The site is so complex now that posting the whole code would be a mess, but I got to narrow the problem testing the simplest form:

    $test = $_GET["c"];
    echo "$test";

    where the url is "whatever/id=4?c=hey"
    and it won't echo anything.

    My site is built on top of Starkers and TwentyTen, and I think that there might be some function around messing with my $_get attempts.
    I know I'm not providing much info, but I don't know where to start looking for the problem. I'm simply out of ideas, and I feel it must be the most simple answer.
    Any hint would be much appreciated.

    I can provide any further info about the site structure that's needed.
    Thanks a lot!

  2. bnvt
    Member
    Posted 3 years ago #

    More info:
    I found that search results don't work in my custom search.php; I believe that search relies on $_POST and $_GET, so this should be related.

    But, I also found that search does work on the original starkers theme search.php so now I'm thinking that the problem might be in my custom loop.
    My loop makes queries through some query_posts() functions, which have been troublesome in the past; I'll have a look at it.

  3. DigitalSquid
    Member
    Posted 3 years ago #

    That URL should be: whatever/?id=4&c=hey

    The question mark goes at the beginning to start the query string and you then use & to add any extra field-value pairs.

    Also, you don't need the quotes around "$test" when using echo. As it's just a variable than echo $test is fine.

  4. bnvt
    Member
    Posted 3 years ago #

    You are absolutely right, thanks a ton.
    I was passing the value to the URL through an anchor rather than a post form, and the href was obviously badly coded.
    Still having problems with the query, though, but I think that's another problem altogether.
    Thanks about the echo tip as well!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags