user3291353
user3291353

Reputation: 1

Fatal error: Class 'Mongo' not found in C:\\Apache Software Foundation\Apache2.2\htdocs\sample\testdb.php

Fatal error:

Class 'Mongo' not found in C:\Apache Software Foundation\Apache2.2\htdocs\sample\testdb.php

Can anyone help me out with this issue? Why is that saying so?

The following is the code that I have used. I have created a database named phptest in MongoDB and inserted a document. Then I tried connecting to MongoDB via PHP but it threw this error.

Can anyone help me get rid of this? I have included the php-mongo dll and saved in php.ini file also.

<?php
echo "succeeded!";
$connection = new Mongo();
$db = $connection->test;
$collection = $db->phptest;
?>

Upvotes: 0

Views: 2977

Answers (2)

Adil
Adil

Reputation: 2112

You're probably using an older version of the Mongo DB driver. The class Mongo has been replaced with MongoClient, since v 1.3.0 of the driver. See this stackoverflow thread :

  1. mongo DB - php driver version
  2. http://www.php.net/manual/en/class.mongo.php

Upvotes: 0

Gilbert Williams
Gilbert Williams

Reputation: 11

Make sure you have the correct php driver installed.

For example if "Thread Safety" is enabled in your php.ini, then make sure you have the "Thread-Safe Mongo Extension" installed and NOT the "Non-Thread-Safe" version.

Upvotes: 1

Related Questions