我将MongoDB与PHP结合使用。我正在使用他们的电子邮件让一个检查用户存在。它可以被检查,但是当我输入现有用户并单击确认按钮时,它会显示'echo'并且还会显示有关将文档转换为int的错误。下面是错误内容和我的代码。
错误:
Notice: Object of class MongoDB\Model\BSONDocument could not be converted to int in C:\xampp\htdocs\project\OrgChart-master\OrgChart-master\memberForgotPassword.php on line 32
Username Exist In Database
代码:
<!-- MongoDB Conn With Email Check Function V1 (FUNCTIONING) -->
<!--Line 32 is at if($result==0)-->
<?php
if(isset($_POST['registration']))
{
$registration = ($_POST['registration']);
if(!empty($registration))
{
$result = $db->collection1->findOne(array("registration"=>$registration));
//print_r($result);
if($result==0)
{
echo "Please Enter The Correct Username";
return false;
}
else
{
echo "Username Exist In Database";
return true;
}
}
}
?>