Answer the question
In order to leave comments, you need to log in
Error creating instance of MongoClient class, what's the problem?
Here is such a function for saving in MongoDB:
function save($data)
{
$m = new MongoClient();
$con = $m->selectDB(DB_NAME)->selectCollection(COLLECTION_NAME);
$con->insert($data);
$m->close();
}
$date = array("name" => "Vika");
save($date);
$m = new MongoClient();
Answer the question
In order to leave comments, you need to log in
The problem was solved! I'll tell you how:
1) Only "Fatal error ..." was displayed in the browser, it was difficult to understand what exactly the error was. I found the logs in the php folder and found this error by date and time. Everything was explained there. The problem was that when connecting to a port, it simply does not find a running database, although it starts automatically for me.
2) I started checking the work of mongo itself, also went into the logs, and saw that it tries to start every time the computer is turned on, but an exception occurs. I'll still deal with this, but as soon as I manually restarted mongo, everything worked)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question