Trying to get property of non-object

« MODX Parse Error »

Error : mysqli_real_escape_string() expects parameter 1 to be mysqli, resource given
Error information
ErrorType[num] WARNING[2]
File /var/www/public_html/includes/catalog.php
Line 499
Source $query = "SELECT * FROM cardscatalog WHERE cardid = '" . mysqli_real_escape_string( $modx->db->conn, $cardid )."'";
Current Snippet TestCatalog

Basic info
REQUEST_URI http://berserk-online.com/spisok_kart.html?sets=4.0
Resource [125] Каталог карт
Referer
User Agent CCBot/2.0 (https://commoncrawl.org/faq/)
IP 54.196.190.32
Current time 2018-11-19 18:44:00

Benchmarks
MySQL 0.0154 s (11 Requests)
PHP 0.0272 s
Total 0.0426 s
Memory 2.0262985229492 mb

Backtrace
DocumentParser->executeParser()
index.php on line 128
DocumentParser->prepareResponse()
manager/includes/document.parser.class.inc.php on line 2141
DocumentParser->parseDocumentSource(string $var1)
manager/includes/document.parser.class.inc.php on line 2218
DocumentParser->evalSnippets(string $var1)
manager/includes/document.parser.class.inc.php on line 2003
DocumentParser->_get_snip_result('TestCatalog')
manager/includes/document.parser.class.inc.php on line 1408
DocumentParser->evalSnippet(string $var1, array $var2)
manager/includes/document.parser.class.inc.php on line 1466
eval()
manager/includes/document.parser.class.inc.php on line 1360
getCatalog()
manager/includes/document.parser.class.inc.php(1360) : eval()'d code on line 2
getCatalog_noAJAX()
includes/catalog.php on line 830
getCatalogText('s-avial', 4.0, '')
includes/catalog.php on line 589
mysqli_real_escape_string($var1, 's-avial')
includes/catalog.php on line 499