I have created mongodb database 'employee' and collection 'personal' into the database. Now I'm trying to connect the db using php, it's connecting but when I'm trying to insert data into the collections, nothing is happened, here is my script :
<?php
// connect to mongodb
error_reporting(0);
$m = new MongoDB\Driver\Manager("mongodb://localhost:27017");
echo "Connection to database successfully"."<br>";
// select a database
$db = $m->employee;
echo "Database selected"."<br>";
$collection = $db->personal;
echo "Collection selected"."<br>";
$collection->insertOne(["name"=>"Rajib", "address"=>"Delhi", "contact"=>123, "gender"=>"Male", "dept"=>"PHP"]);
echo "Document inserted successfully";
?>
What's wrong here?