Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
&引用;“如何修复”;此函数在MongoDB PHP中调用getMatchedCount()_Php_Mongodb_Mongodb Php - Fatal编程技术网

&引用;“如何修复”;此函数在MongoDB PHP中调用getMatchedCount()

&引用;“如何修复”;此函数在MongoDB PHP中调用getMatchedCount(),php,mongodb,mongodb-php,Php,Mongodb,Mongodb Php,这是我用来检查用户名可用性的代码。我认为getMatchedCount()方法/函数有问题。这是因为,我一直在那一行得到一个错误,错误是: 'Fatal error: Uncaught Error: Call to a member function getMatchedCount() on null in C:\xampp\htdocs\project\OrgChart-master\OrgChart-master\memberForgotPassword.php:35 Stack trace

这是我用来检查用户名可用性的代码。我认为
getMatchedCount()
方法/函数有问题。这是因为,我一直在那一行得到一个错误,错误是:

'Fatal error: Uncaught Error: Call to a member function getMatchedCount() on null in C:\xampp\htdocs\project\OrgChart-master\OrgChart-master\memberForgotPassword.php:35 Stack trace: #0 {main} thrown in C:\xampp\htdocs\project\OrgChart-master\OrgChart-master\memberForgotPassword.php on line 35'
如何解决这个问题?或者有没有其他方法可以从
mongodb
数据库检查用户名可用性

首先,感谢您对我的帮助。:)


对不起,我的朋友,但是我不明白b)好的,那么我应该怎么做来修复这个错误呢?我遵循文档,它根本不起作用。嗯:(是的,它显示为一个新的错误调用,`
注意:MongoDB\Model\BSONDocument类的对象无法在C:\xampp\htdocs\project\OrgChart master\OrgChart master\memberForgotPassword.php的第36行转换为int,那么我应该怎么做来修复这个错误呢?我遵循文档,它根本不起作用。Hmm:(是的,它显示为一个新的错误调用,`
注意:MongoDB\Model\BSONDocument类的对象无法在第36行的C:\xampp\htdocs\project\OrgChart master\OrgChart master\memberForgotPassword.php中转换为int
if(isset($_POST['registration']))
{
       $registration = ($_POST['registration']);

       if(!empty($registration))
       {
            //$cursor = $collection->find(array("registration" => $registration));
            //$result = $cursor->count();

            $result = $db->collection1->findOne(array("registration"=>$registration));
            if($result->getMatchedCount()==0)
            {
                echo "Username Available";
            }
            else
            {
                echo "Please Enter The Correct Username";
            }

       }
 }