I want to make a php app that uses Mongodb.
When I run the app on the localhost I get this:
Fatal error: Uncaught exception 'MongoConnectionException' with message 'Failed to connect to: 127.0.0.1:27017: Timed out after 1000 ms'
My code is:
<?php
// Config
$dbhost = 'localhost';
$dbname = 'test';
// Connect to test database
$m = new Mongo("mongodb://$dbhost");
$db = $m->$dbname;
// select the collection
$collection = $db->shows;
// pull a cursor query
$cursor = $collection->find();
foreach($cursor as $document) {
var_dump($document);
}
?>