I am using PHP for 1st time.
I am just trying to fetch data from database. Here is my code -

```
        try{
            ///try to connect with database
            $conn=new PDO("mysql:host=localhost:3306;dbname=try", "root", "abcdef12");
            $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        }
        catch(PDOException $ex){
            echo "error";
        }
        $mysqlcode="SELECT * FROM users";
        $ret=$conn->query($mysqlcode);
        foreach($ret as $ret1)
        print $ret1->id;

```

in the browser,
showing this error:

> 
> Notice: Trying to get property 'id' of non-object in /opt/lampp/htdocs/secAsite/verifylogin.php on line 44
> 
> 
> 

In the users table, I have 4 data.
In here, why $ret seems non object. I can't find anything wrong. How to fetch data. Or debug the object.