title: Replace variable with query
body: <p>I am pretty new to using mysql and variables in php.</p>
  
  <p>I have this code </p>
  
  <pre><code>mysql_query("INSERT INTO `forum_threads` (`name`, `byid`, `cid`,
  `content`, `time`, `lastreplied_time`, `lastreplier_id`) VALUES
  ('{$title}', '{$uid}', '{$cid}', '{$content}', '" . time() . "', '" .
  time() . "', '{$uid}');") or die(mysql_error());
  </code></pre>
  
  <p>In my php file, I want <code>byid</code> to be the value of <code>id</code> in my table <code>forum_users</code>. So can I replace <code>{$uid}</code> with something that will get the value from <code>forum_users</code>. Because I don't think {$uid} is working correct.</p>
  
  <p>I found this code</p>
  
  <pre><code>/* Non-existant forum account */ final public function
  createForumAccount($uid) {
      $getHabboUser = mysql_query("SELECT * FROM
          `users` WHERE `id` = '{$uid}' LIMIT 1");
  </code></pre>
  
  <p>I assume that the function of that code is to get the <code>{$uid}</code> equal the <code>id</code> from the <code>users</code> table, I want to make the <code>{$uid}</code> to equal the id from the <code>forum_users</code> table.</p>
  
  <p>Then I found this code:</p>
  
  <pre><code>final public function getUserData($uid, $var) {
      if($this-&gt;checkForAccount($uid) == true) {
          $check = mysql_query("SELECT `{$var}` FROM `forum_users` WHERE `uid` = '{$uid}' LIMIT 1") or die(mysql_error());
          return mysql_result($check, 0);
      }
  }
  </code></pre>
  
  <p>That code wants the <code>{$uid}</code> to equal forum_users <code>id</code>. And that is exactly what I want, but it doesn't equal that, it equals the <code>id</code> from the <code>users</code> table instead, I assume it might collide with eachother or something.</p>
  
  <p>How can I solve this? Can I replace <code>{$uid}</code> in my first code, so <code>byid</code> is selected instantly from <code>forum_users</code>? Can I make a new variable that equals <code>forum_users.id</code>?</p>