How do I set a variable to $_GET
<p>I don't have a lot of experience with this... Help is greatly appreciated.</p>

<p>$id = $_GET["categoryID"]; isn't setting the variable.</p>

<p>$_GET["categoryID"] is returning the value, but the variable isn't being set. </p>

<p>I can set the variable by using $id=3; however $id = $_GET["categoryID"]; doesn't work.</p>

<pre><code>&lt;?php 
if (@$_REQUEST['ajax']) {
        $link = $nm3;
    if ($link == false)
        trigger_error('Connect failed - ' . mysql_error(), E_USER_ERROR);
    $connected = mysql_select_db('dgp', $link);

    if ($connected) {


        $id = $_GET["categoryID"];


        $results = mysql_query('select * from selectMenu where categoryID= \'' . $id . '\' AND category="' . strtolower(mysql_real_escape_string(strip_tags($_REQUEST['category']))) . '"');

        $json = array();
        while (is_resource($results) &amp;&amp; $row = mysql_fetch_object($results)) {
            //$json[] = '{"id" : "' . $row-&gt;id . '", "label" : "' . $row-&gt;label . '"}';
            $json[] = '"' . $row-&gt;label . '"';
        }
        echo '[' . implode(',', $json) . ']';
        die(); // filthy exit, but does fine for our example.
    } else {
        user_error("Failed to select the database");
    }
}
?&gt;
</code></pre>

<hr>

<p>Ok, so I stripped everything down as far as I know how. it appears the problem may be related to the ajax request.</p>

<p>Here is the stripped down code using $_GET.... $id=$_GET["categoryID"]. It prints the $_GET["categoryID"] result and the $id.</p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;Test $_GET&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;?php 
        if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) &amp;&amp; strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
        $id = $_GET["categoryID"];
        }
?&gt;
  print_r($_GET) = &lt;?php print_r($_GET); ?&gt;
  &lt;br /&gt;
  print_r($id) = &lt;?php print_r($id); ?&gt; 
&lt;/body&gt;
&lt;/html&gt; 
</code></pre>

<hr>

<p>And here is the post page sample....</p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;testPOST&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form action="testPOST.php" method="post"&gt;
  categoryID: &lt;input type="text" name="categoryID" /&gt;&lt;br /&gt;
  &lt;input type="submit" value="Submit" /&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>And the Post result page...</p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
    &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
    &lt;head&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
    &lt;title&gt;Test $_POST&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
    &lt;?php 
            if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) &amp;&amp; strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
            $id = $_POST["categoryID"];
            }
    ?&gt;
      print_r($_POST) = &lt;?php print_r($_POST); ?&gt;
      &lt;br /&gt;
      print_r($id) = &lt;?php print_r($id); ?&gt; 
    &lt;/body&gt;
    &lt;/html&gt;
</code></pre>

<p>It still isn't setting the $id = $_GET["categoryID"]; Even though is is printing it outside of the request block Thanks again for all your help.</p>
