duanfengwang9157 2013-07-25 07:40
浏览 49

无法使用php从ubuntu连接到Windows服务器上的Mongodb

I wanted to connect to the MongoDB which is installed in windows server from ubuntu using php. I am trying to connect using the following code but output is nothing even mongoexception is not throwing any error.

$mngo = new Mongo("mongodb://192.168.1.119:27017");
$db = $mngo->selectDB('travelmanagement_qa');

Can anyone please tell me why i am not able to connect? Thank You in advance

  • 写回答

1条回答 默认 最新

  • dtx6087 2013-07-25 09:13
    关注

    A few comments:

    • Please use new MongoClient instead of new Mongo.
    • This should not output anything at all. You're just selecting a database and assigning it to a variable. Is that your whole code snippet?
    • What did you expect the output to be?

    To figure out what is actually happening under the hood with connections you can use MongoLog. With this functionality you can track down what the driver is doing internally. You'd use it like:

    MongoLog::setLevel(MongoLog::ALL);
    MongoLog::setModule(MongoLog::RS);
    MongoLog::setCallback( 'printMsgs' );
    
    function printMsgs($a, $b, $msg)
    {
        echo $msg, "
    ";
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 spring后端vue前端
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题