title: Cannot use object of type PDOStatement as array
body: <p>I want to check if some column of specify user is holding a value higher than 0.</p>
  
  <p><strong>Problem</strong></p>
  
  <p>When doing the query, and <strong><em>then executing it</em></strong>, Im getting this error:</p>
  
  <pre><code>Fatal error: Cannot use object of type PDOStatement as array in C:\xampp\htdocs\recover\admin\create.php on line 40
  </code></pre>
  
  <p>My code (The query + execute):</p>
  
  <pre><code>if (isset($_SESSION['user'])) {
          $admin = $CONNECT_TO_DATABASE-&gt;prepare("SELECT * FROM admin WHERE username = :username");
          $admin-&gt;bindValue(':username', $_SESSION['user']);
          $admin-&gt;execute();
  </code></pre>
  
  <p>Line of error (40):</p>
  
  <pre><code>if ($settings['create_admins'] &gt; 0 || $admin['super_admin'] &gt; 0 ) {
  </code></pre>
  
  <p><strong>Question:</strong></p>
  
  <p>Why am I getting this error? How do I fix it?</p>
  
  <p>I tried doing this:</p>
  
  <pre><code>$admin = $CONNECT_TO_DATABASE-&gt;prepare("SELECT * FROM admin WHERE username = :username");
  $admin = $admin-&gt;bindValue(':username', $_SESSION['user']);
  $admin = $admin-&gt;execute();
  </code></pre>
  
  <p>and getting another error:</p>
  
  <pre><code>Fatal error: Call to a member function execute() on a non-object in C:\xampp\htdocs\recover\admin\create.php on line 38
  </code></pre>
  
  <p>Thanks!</p>
  
  <p>EDIT: I need the ->fetch object, but I have just done this, and got rid of the errors.. But it doesn't affect? I mean I am echoing that row, and it gives me a null (nothing). Why?</p>
  
  <pre><code>$admin = $CONNECT_TO_DATABASE-&gt;prepare("SELECT * FROM admin WHERE username = ".$_SESSION['user']."");
  $admin = $admin-&gt;fetch();
  </code></pre>