title: How do I compare input to mysql data with php/sql?
body: <p>I'm new to working with PHP and a mySQL DB.  I"m trying to make a user input there user name(UN) to enter this one part of my site. I have a mySQL DB(test) with a users table called "test".
    I know that I'm connecting ok, because I tested it by creating a simple page to open the DB and list all the users(from the UN field), or select a specific one.  I then created a page called "input.php" for a test of getting input. As seen here> </p>
  
  <pre><code>&lt;html&gt;
   &lt;body&gt;
   &lt;form action="test.php" method="get"&gt;
   UN: &lt;input type="text" name="U"&gt;
   &lt;input type="submit"&gt;
   &lt;/form&gt;
   &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>
  
  <p>The input from above goes to "test.php" below where it is checked with current data in my DB.</p>
  
  <pre><code>&lt;?php
  $hostname = "test.db.some#.somehost.com";
      $username = "test";
      $dbname = "test";
  $password = "password";
  $usertable = "test";
  $yourfield = "UN";
      mysql_connect($hostname, $username, $password) OR DIE ("Unable to 
          connect to database! Please try again later.");
      mysql_select_db($dbname);
  $query = "SELECT * FROM $usertable WHERE $yourfield = $_GET["U"]";
      $result = mysql_query($query);
      if ($result) {
          while($row = mysql_fetch_array($result)) {
                  $name = $row["$yourfield"];
                  echo "Hello: $name&lt;br&gt;";
              }
      }
      else {
          echo "User dosen't exit!";
      }
      mysql_close();
  ?&gt;
  </code></pre>
  
  <p>And this is the error I get> *Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/81/11107981/html/test.php on line 20*</p>
  
  <p>I know I'm close, but I want the cigar. ;)</p>