1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Php getting argument using $_GET

Discussion in 'PHP' started by rekha, Oct 30, 2008.

  1. rekha

    rekha New Member


    I have a php page where i am getting argument from another page.The argument contains values similar to "Repair & Maintenance".If i retrieve that argument using $_GET method i am getting only "Repair" as the value.I need the value to be "Repair & Maintenance".How can i get this.

  2. shabbir

    shabbir Administrator Staff Member

    You submitted the thread as article and I have moved it to forums for discussion.
  3. pete_bisby

    pete_bisby New Member

    The ampersand is causing the break in the URL - PHP populates the $_GET array from the URL. Everything to the right of the question mark goes to the $_GET array, with each pair of key/values.
    $_GET["field1"] = "value1"
    $_GET["field2"] = "value2"

    Now because you have an ampersand in the URL, PHP thinks it is a new variable, which is the reason why the second half is disappearning.

    The solution: encode the URL correctly - look at htmlentities(), htmlspecialchars() or urlencode()
  4. pradeep

    pradeep Team Leader

    Use urlencode

    $url "http://www.go4expert.com/index.php?value=".urlencode('Repair & Maintenance');

Share This Page