title: How to replace username with link in string?
body: <p>I'm trying to check posts to see whether they mention another user, by using @username. I want to replace that with a link to the user's profile.</p>
  
  <p>This is what I've got... I haven't got any errors, but usernames just go through as text without the link. I feel like $getUsers/$gU isn't returning the results to $checkString, but I can't see anything wrong.</p>
  
  <pre><code>function post()
  {
    global $me;
  
    if($_POST['message'])
    {
      $getUsers = mysql_query("SELECT user_id, user_name FROM users");
      while($gU = mysql_fetch_array($getUsers))
      {
        $checkString = strpos($_POST['message'], "@".$gU['user_name']."");
        if($checkString !== false)
        {
          $replaceFrom = "@".$gU['user_name']."";
          $replaceTo = "&lt;a href=\'/user.php?id=".$gU['user_id']."\'&gt;".$gU['user_name']."&lt;/a&gt;";
          $checked = str_replace($replaceFrom, $replaceTo, $_POST['message']);
        }
        else
        {
          $checked = $_POST['message'];
        }
      }
      mysql_query("INSERT INTO test_table VALUES ('', '".$me['user_id']."', '".$_POST['topic']."', '".$checked."', UNIX_TIMESTAMP())");
      index();
    }
    else {
      echo "
      &lt;form action='?action=insert' method='post'&gt;
      &lt;input type=text name=topic maxlength=40&gt;
      &lt;br&gt;&lt;textarea name=message cols=80 rows=9&gt;&lt;/textarea&gt;
      &lt;br&gt;&lt;input type='submit' STYLE='color: black;  background-color: white;' value='Submit' class='btn'&gt;
      &lt;/form&gt;
      ";
    }
  }
  </code></pre>