PHP Help

Discussion in 'Technology' started by Phil Mitchell, Nov 11, 2007.

Users Viewing Thread (Users: 0, Guests: 0)

  1. Phil Mitchell

    Phil Mitchell check me a dollar brer?

    Joined:
    May 19, 2005
    Messages:
    8,831
    Likes Received:
    1
    Location:
    Melbourne
    PHP Help

    hopefull someone can answer this

    I want to take an input from a text field in a form and turn that text into a $ which will then form part of a query for MySQL

    e.g

    user enters 'john'
    submits form to directs to php page

    /////in next document////
    $username_POST["username"]

    $result2 = mysqli_query($conn, "SELECT DISTINCT * FROM users, myreviews WHERE userid ='$username';");



    obviously that above doesnt work so how do you do it?

    cheers
  2. 1615634792921.png
  3. trance_fan

    trance_fan Registered User

    Joined:
    Nov 7, 2002
    Messages:
    9,022
    Likes Received:
    0
    I'm not entirely sure what you mean here, but:

    $username_POST["username"]

    really doesn't look right?

    should it not be $username = $_POST["username"];

    ?
  4. Yosef Ha'Kohain

    Yosef Ha'Kohain Registered User

    Joined:
    Nov 11, 2001
    Messages:
    20,386
    Likes Received:
    5
    Location:
    Zion
    You described two different things... if you want to simply call the input do as chris says... if you want to use that input as part of a new variable name use brackets eg.

    $username = phil
    $userid = 1

    ${$username.$userid} would equal $phil1
  5. Phil Mitchell

    Phil Mitchell check me a dollar brer?

    Joined:
    May 19, 2005
    Messages:
    8,831
    Likes Received:
    1
    Location:
    Melbourne
    cheers for the help, figured it out about 3 seconds after i made the post :lol:

Share This Page