I can't get this script that uses PDO object and MySQL with user-defined variables to work. I learned that with PDO you can't execute two queries in one call, so I split it to two `query()` calls. But it's still not working. Here is an abstract from my script (connection to MySQL is of course done in a different file, I copied it here so it's all in one place just for the purposes of this question):

```
 $db_hostname = 'localhost';
 $db_username = 'username';
 $db_password = 'pwd';
 $db_name = 'dbname';
 $dsn = "mysql:dbname=$db_name; host=$db_hostname";

 $pdo = new PDO($dsn, $db_username, $db_password);
 $strsql = "SET @num := 0, @tp := ''";

 $result=$pdo->query($strsql);

 $strsql = "SELECT " . $offer . "_tp AS tp, " . $offer . "_level AS best_offer, Price
           FROM (
                SELECT " . $offer . "_tp, " . $offer . "_level, Price, 
                    @num := if(@tp = `" . $offer . "_tp`, @num + 1, 1) as level,
                    @tp := `" . $offer . "_tp` as dummy
                FROM tbl_limit_offers
                WHERE Prod_Code = $procCode) as x               
           WHERE x.level = 1";
 $result = $pdo->query($strsql);
 echo $result->rowCount()

```

If I run that query directly in PHPmyAdmin it returns several records. However, running it with PDO object I get:

> 
> Fatal error: Call to a member function rowCount() on a non-object
> 
> 
> 

`$result` should be a `PDOStatement` object and `rowCount()` should be one of its methods. So, why is it not working?