diff --git a/lib/punbb/include/dblayer/pgsql.php b/lib/punbb/include/dblayer/pgsql.php
index 5f94eec23510d1b9eb7260c875fec4ee5435ff44..9ee0f2edd870645a625bf03fffd4092d779a1455 100644
--- a/lib/punbb/include/dblayer/pgsql.php
+++ b/lib/punbb/include/dblayer/pgsql.php
@@ -122,7 +122,7 @@ class DBLayer
 
 			++$this->num_queries;
 
-			$this->last_query_text[$this->query_result] = $sql;
+			$this->last_query_text[(int)$this->query_result] = $sql;
 
 			return $this->query_result;
 		}