I am trying to insert a document using PHP for my project but the code is not working.
for reference, I have echoed "still here" and "done".
But the code is not able to execute the insert query please help.
I have already tried all the stack overflow and other sites but non of them work properly.
<?php
require 'vendor/autoload.php';
include 'lib/JSON.php';
// connect to mongodb
$client = new MongoDB\Client("mongodb://localhost:27017");
// select a database
$db = $client->hm;
$collection = $db->sc;
$count = $collection->count();
$document = array("_id" => $count,
"device_id" => 100,
"pin" => 17,
"status" => "True");
echo "still here";
$collection->insert($document);
echo "done"
?>
I am only getting "still here" on browser.