【发布时间】:2018-02-23 14:17:15
【问题描述】:
最近我成功地将我的 Wamp 服务器从 Wamp 2.5 升级到了 Wamp 3.0。 现在,在我的 Wamp 3.0 服务器中,PHP 的版本为 5.6.31。
我从https://pecl.php.net/package/mongodb 下载了 MongoDB 驱动程序(稳定版 1.2.10),并成功安装到我的 Wamp 服务器中。服务器将 mongodb 显示为加载的扩展之一。
我遇到错误消息:致命错误:在线 C:\wamp64\www\loginNew.php 中找不到 Class 'MongoClient' ...
该 PHP 代码在以前版本的 Wamp(和 PHP)中运行良好。这是代码
// connect to mongodb
$m = new MongoClient();
// select a database
$db = $m->ConsentForm;
$collection = $db->ConsentFormDetail;
$agreeBoolean = $_POST['agree'];
$nameInitial = $_POST['initial'];
$informedBoolean = $_POST['informed'];
$email = $_POST['emailAddress'];
$consentForm = array(
"agreeBoolean" => $agreeBoolean,
"nameInitial" => $nameInitial,
"timeOfSigning" => date("Y-m-d H:i:s"),
"informed" => $informedBoolean,
"email" => $email
);
$collection->insert($consentForm);
echo "You have Successfully Signed the consent form.....";
?>
经过一番搜索,我替换了
$m = new MongoClient();
与
$m = new MongoDB\Driver\Manager("mongodb://localhost:27017");
然后出现如下错误信息:Notice: Undefined property: MongoDB\Driver\Manager::$MergedParticipant in C:\wamp64\www\loginNew.php on line ...
你能帮忙吗,
非常感谢
【问题讨论】:
-
请检查我的回答,这可能会对您的问题有所帮助:为什么找不到 MongoClient() 类。 stackoverflow.com/a/46324135/1696621