Im trying to run a different query depending on the amount of results from the table. 

I have the following but it only outputs the text at the end, not the 'echo' data?

Can anybody see what Im doing wrong?

```
<?php

require 'dbconfig.php';

class User {

    function checkUser($uid, $oauth_provider, $username, $email, $twitter_otoken, $twitter_otoken_secret) 
    {

        $query = "SELECT * FROM `users` WHERE oauth_uid = '$uid' and oauth_provider = '$oauth_provider'";

        $result = $DBH->query($query);

        if (!empty($result)) {
                echo 'user';
        } else {
                echo 'no user';
        }

        $DBH = null;

    }

}
?>

Test page loads

```

---

**Calling the class**

On another page I call my class with the below

```
    ...else {
       $twitter_otoken=$_SESSION['oauth_token'];
       $twitter_otoken_secret=$_SESSION['oauth_token_secret'];
       $email='';
        $uid = $user_info->id;
        $username = $user_info->name;
        $user = new User();
        $userdata = $user->checkUser($uid, 'twitter', $username,$email,$twitter_otoken,$twitter_otoken_secret);
        if(!empty($userdata)){
            session_start();
            $_SESSION['id'] = $userdata['id'];
 $_SESSION['oauth_id'] = $uid;
            $_SESSION['username'] = $userdata['username'];
            $_SESSION['oauth_provider'] = $userdata['oauth_provider'];
            header("Location: splash.php");
        }
    }
} else {
    // Something's missing, go back to square 1
    header('Location: login-twitter.php');
}
?>

```

**Config**

```
$host = 'localhost';
$dbname = 'dbname was here';
$user = 'access';
$pass = 'access';

try {
  $DBH = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
  $DBH->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );

    } catch(PDOException $e) {  
        echo $e->getMessage();  
    }  

?>

```