title: PHP Variable in Select Statement
body: <p>I've written this PHP-Script which is working, and now I want to change the row name into a variable to (not sure if row is correct), I mean the "name" from the <em>select <strong>name</em></strong>...
  I've tried nearly everything, but nothing gave me the right result.
  I know that the normal thing how I can use variables in a statement like ("'. $var .'") won't work.</p>
  
  <pre><code>&lt;?php
  require_once 'config.php';
  
  $id = $_GET["id"]; //ID OF THE CURRENT CONTACT
  $user = $_GET["user"];  //ID OF THE CURRENT USERS
  
  $query = mysql_query("SELECT name FROM contacts WHERE contact_id='". mysql_real_escape_string( $id ) ."' and user_id='1';");
  
  $retval = mysql_fetch_object($query)-&gt;name;
  
  $retval = trim($retval);
  echo $retval;
  ?&gt;
  </code></pre>