I’m trying to connect to mongodb in php.
There’s no problem if mongodb is start in shell with mongod command.
new Mongo("mongodb://".$_host.":".$_port,true)
But when i start mongodb server as a service, i can connect with the mongo command, but i cant connect in php.
new Mongo("mongodb://".$_host.":".$_port,true)
Is there any other arguments?
I’m using the last version of mongodb and the last version of php.
Can someone help me?
Thanks for your answer and comment, i fix it.
The problem was in the service command line , i use this command
instead of
In the php code
new Mongo("mongodb://".$_host.":".$_port,true), $host = myIPadressThat why it was working in command line and not in the php code, it must be the same IPadress, don’t use localhost or something like that if you don’t use a default
new Mongo()