Index: lib/Doctrine/ORM/Query.php
===================================================================
--- lib/Doctrine/ORM/Query.php	(revision 6679)
+++ lib/Doctrine/ORM/Query.php	(working copy)
@@ -207,7 +207,16 @@
         $sqlParams = array();
         
         $paramMappings = $this->_parserResult->getParameterMappings();
+
+        if(count($paramMappings) != count($params)) {
+            throw new QueryException("Invalid parameter number: number of bound variables does not match number of tokens");
+        }
+
         foreach ($params as $key => $value) {
+            if(!isset($paramMappings[$key])) {
+                throw new QueryException("Invalid parameter: token ".$key." is not defined in the query.");
+            }
+
             if (is_object($value)) {
                 $values = $this->_em->getClassMetadata(get_class($value))->getIdentifierValues($value);
                 $sqlPositions = $paramMappings[$key];
Index: tests/Doctrine/Tests/ORM/Functional/QueryTest.php
===================================================================
--- tests/Doctrine/Tests/ORM/Functional/QueryTest.php	(revision 6679)
+++ tests/Doctrine/Tests/ORM/Functional/QueryTest.php	(working copy)
@@ -102,5 +102,39 @@
         $this->assertEquals('Symfony 2', $users[0]->articles[1]->topic);
     }
 
+    public function testUsingUnknownQueryParameterShouldThrowException()
+    {
+        $this->setExpectedException(
+            "Doctrine\ORM\Query\QueryException",
+            "Invalid parameter: token 2 is not defined in the query."
+        );
+
+        $q = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = ?1');
+        $q->setParameter(2, 'jwage');
+        $user = $q->getSingleResult();
+    }
+
+    public function testMismatchingParamExpectedParamCount()
+    {
+        $this->setExpectedException(
+            "Doctrine\ORM\Query\QueryException",
+            "Invalid parameter number: number of bound variables does not match number of tokens"
+        );
+
+        $q = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = ?1');
+        $q->setParameter(1, 'jwage');
+        $q->setParameter(2, 'jwage');
+
+        $user = $q->getSingleResult();
+    }
+
+    public function testInvalidInputParameterThrowsException()
+    {
+        $this->setExpectedException("InvalidArgumentException");
+
+        $q = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = ?');
+        $q->setParameter(1, 'jwage');
+        $user = $q->getSingleResult();
+    }
 }
 
