为了账号安全,请及时绑定邮箱和手机立即绑定

出现错误“PHP 消息:PHP 致命错误:未捕获错误:

出现错误“PHP 消息:PHP 致命错误:未捕获错误:

PHP
神不在的星期二 2023-04-15 20:22:03
我已经在我的服务器上安装了 MongoDB,我正在尝试运行这个脚本:<?php$client = new MongoClient();$collection = $client->cryptnote->storedMessages;function insertDocument($collection, $id, $telegramuser, $message) {    $doc = array(        "id" => $id,        "telegram" => $telegramuser,        "encrypted" => $message,    );    try {        $collection->insert($doc);    } catch(Exception $e) {        echo "Error" . $e;    }}function findDocument($collection, $id){    return $collection->findOne(["id" => $id]);}insertDocument($collection, "test123", "usertest", "message. test.");$query = findDocument($collection, "test123");echo "<pre>";var_dump($query);这是我得到的错误: Got error 'PHP message: PHP Fatal error:  Uncaught Error: Class 'MongoClient' not found in /var/www/html/dbtest.php:5我的 Apache 服务器使用/etc/php/7.3/fpm/php.ini根据phpinfo();.添加extension=mongodb.so到php.ini文件是没有用的。
查看完整描述

1 回答

?
倚天杖

TA贡献1828条经验 获得超3个赞

解决方案是重新启动php-fpm

在我的例子中,我安装了 PHP 7.3 版,所以我需要运行这个命令: sudo service php7.3-fpm restart


查看完整回答
反对 回复 2023-04-15

添加回答

代码语言

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号