0
votes

I just want to create mongoDB client(1.2.9) using PHP7 in Ubuntu 16.04 LTS.

I Just getting error from Apache log as below.

PHP Fatal error: Uncaught MongoDB\Driver\Exception\InvalidArgumentException: Failed to parse MongoDB URI: 'mongodb:/192.168.0.160:27017' in /var/www/html/db.php:4\nStack trace:\n#0 /var/www/html/db.php(4): MongoDB\Driver\Manager->__construct('mongodb:/192.16...')\n#1 {main}\n thrown in /var/www/html/db.php on line 4

1
mongodb://192.168.0.160:27017 you were missing a slash / - Neil Lunn
after adding "/" i got this error [Thu Aug 10 15:42:20.567779 2017] [:error] [pid 26566] [client 192.168.0.203:51667] PHP Fatal error: Uncaught MongoDB\\Driver\\Exception\\RuntimeException: not authorized on testDb to execute command { find: "testColl", filter: { age: 30 } } in /var/www/html/db.php:10\nStack trace:\n#0 /var/www/html/db.php(10): MongoDB\\Driver\\Manager->executeQuery('testDb.testColl', Object(MongoDB\\Driver\\Query))\n#1 {main}\n thrown in /var/www/html/db.php on line 10 - Yogesh Upadhyay
Well that's because you did not provide a username or password as required. It's also what we call a different question here. If you have a new question then Ask a new Question - Neil Lunn
I getting this type error,[Fri Aug 11 09:30:05.985765 2017] [:error] [pid 31307] [client 192.168.0.203:57805] PHP Notice: Undefined property: MongoDB\\Driver\\Manager::$admin in /var/www/html/mongo.php on line 8 [Fri Aug 11 09:30:05.985829 2017] [:error] [pid 31307] [client 192.168.0.203:57805] PHP Notice: Trying to get property of non-object in /var/www/html/mongo.php on line 10 - Yogesh Upadhyay

1 Answers

1
votes

I think you have this mistake in connection url :

mongodb://192.168.0.160:27017

after: mongodb: need two // or you choose a database php can't connect to mongo database read this issue.