title: PHP query single line from database
body: <p>I'm having a problem echoing a single line from a sql query. I'm still pretty new at this but I can't figure it out at all.</p>
  
  <p>I have a page titled "listing.php?id=7"</p>
  
  <p>Inside the page is this script:</p>
  
  <pre><code>&lt;?php
      mysql_connect("localhost", "user", "pass"); 
      mysql_select_db("table"); 
  
      $query = "SELECT * FROM vehicles WHERE id='$id'";
      $result = mysql_query($query);
  
      while($r = mysql_fetch_array($result))
      {   
          $year = $r["year"];
          $make = $r["make"];
          $model = $r["model"];
          $miles = $r["miles"];
          $pricepay = $r["pricepay"];
          $pricecash = $r["pricecash"];
          $transmission = $r["transmission"];
          $color = $r["color"];
          $vin = $r["vin"];
  
          echo "$year $make $model $miles $pricepay $pricecash $transmission $color $vin&lt;br /&gt;";
      }
  ?&gt;
  </code></pre>
  
  <p>The problem lies within "WHERE id='$id'". When I use a var, it displays nothing, but if I manually make it my ID number, example 7, it works fine. What's am I doing wrong?</p>