I have a problem connecting to MongoDB with PHP. This is my code:
<?php
$server = new Mongo('localhost:27017');
$db = $server->sampleDB;
$coll = $db->sample;
?>
This results in the following error:
Fatal error: Uncaught exception 'MongoConnectionException' with message 'localhost:27017: couldn't get host info for localhost' in /var/www/example/index.php:2 Stack trace: #0 /var/www/example/index.php(2): Mongo->__construct('localhost:27017') #1 {main} thrown in /var/www/wexample/index.php on line 2
user179169
source
share