$1 represents the value of the brackets located here:
/\[poll(\d+)\]/i. $0 would be the entire matched string, which is typically a useless chunk for something like a preg_replace.
I ran that test above on codepad (I was surprised it worked since they have issues with pattern compiling). The results are a copy/paste of the source it generated. It may be wiser to use backreference with \1 instead of $1.
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php