title: Object of class User could not be converted to string
body: <p>I'm working on a forum software currently.</p>
  
  <p>I have a class called User, within that class I have a method called GetUserGroup to determine what group the user is in.</p>
  
  <p>I am running the query and assoc the same way I've been doing with all my other queries, I'm not sure what I'm doing wrong, I've looked over the query for syntax errors but just don't see any.</p>
  
  <p>Catchable fatal error: Object of class User could not be converted to string in C:\xampp\htdocs\forums\index.php on line 22</p>
  
  <p>Here's the whole page:</p>
  
  <pre><code>&lt;?php 
  include_once('connect.php');
  session_start();
  
  if (isset($_SESSION['username'])) {
      $username = $_SESSION['username'];
  
  }
  
  class User {
  
      public $usergroup;
      public $user;
  
      function __construct() {
          if (isset($_SESSION['username'])) {
              $this-&gt;user = $_SESSION['username'];
          }
      }
  
      public function GetUserGroup() {
          $find_group = "SELECT group FROM users WHERE username='$this-&gt;user'";
          $run_find_group = mysql_query($find_group);
          $find_group_assoc = mysql_fetch_assoc($run_find_group);
          $this-&gt;usergroup = $find_group_assoc['group'];
      }
  }
  
  class Forum {
  
      function __construct() {
  
      }
  
      public function DisplayForums() {
  
          $find = "SELECT id,name,description FROM forums";
          $run_find = mysql_query($find);
  
          while ($is = mysql_fetch_assoc($run_find)) {
              $forum_id = $is['id'];
              $forum_name = $is['name'];
              $forum_description = $is['description'];
  
              echo "&lt;div  style='background:#FF6699;width:1000px;'&gt;";
              echo "Forum: &lt;a href='topics.php?t='$forum_id'&gt;".$forum_name."&lt;/a&gt;&lt;br/&gt;".$forum_description."&lt;br/&gt;&lt;hr&gt;";
              echo "&lt;/div&gt;";
          }
      }
  }
  
  $forum = new Forum();
  if (isset($_SESSION['username'])) {
      $_SESSION['username'] = new User();
      $_SESSION['username']-&gt;GetUserGroup();
  }
  ?&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Home&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;?php 
  if (isset($_SESSION['username'])) {
      echo "Welcome, " . $username . "!";
      if ($_SESSION['username']-&gt;usergroup==admin) {
          echo "&lt;span align='right'&gt;&lt;a href='/admin/index.php'&gt;Admin CP&lt;/a&gt;&lt;/span&gt;";
      }
      $forum-&gt;DisplayForums(); 
  } else {
      $forum-&gt;DisplayForums(); 
      echo "
      &lt;form action='login.php' method='post'&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;Username: &lt;/td&gt;
              &lt;td&gt;&lt;input type='text' name='username' /&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Password: &lt;/td&gt;
              &lt;td&gt;&lt;input type='text' name='password' /&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;input type='submit' name='login_submit' value='Login' /&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
      &lt;/form&gt;";
  }
  ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>