Posts

Showing posts from January 14, 2019

Undefined property: MongoDBDriverManager::$db

Image
0 I have a local MongoDB database running on WAMP on Windows 10. I'm using PHP version 7.2.10, Apache 2.4.35, and MongoDB extension 1.5.3. I have a pretty simple web application that I'm testing, and when I try to send data to my database via a php script, I get this error: PHP Notice: Undefined property: MongoDBDriverManager::$db in C:wamp64wwwphptest.php Relevant parts of test.php , the file in question, look like this: $objectId = new MongoDBBSONObjectId(); $dbhost = "127.0.0.1:27017"; $dbname = "db"; $m = new MongoDBDriverManager("mongodb://localhost:27017"); var_dump($m); $db = $m->$dbname; The property being undefined results in another error: Fatal error: Uncaught Error: Call to a member function selectCollection() on null which causes the script to