0

I tryed connect to Mlab with php by following code:

$connection = new MongoClient('mongodb://user:pass@ds051605.mlab.com:51605/db');

This code worked correctly in my system but didn't work in host and reterned Error 500 (my host doesn't support from mongo). What is the problem? Is there need to supporting mongo in host? Additionaly, var_dump($connection) command doesn't show error.

ParisaN
  • 1,816
  • 2
  • 23
  • 55
  • A 500 error means that a server error occurred. This is most likely an error in your PHP-code. To see the _actual_ error message, check your servers error log. You can also change how PHP displays errors and tell it to show all errors directly on the screen (this is not something you want in production though, since it can show sensitive data, but during development, you should). Here's how to show all errors and warnings: https://stackoverflow.com/questions/5438060/showing-all-errors-and-warnings – M. Eriksson Jul 28 '17 at 12:11
  • Are you created user or add permissions on specify database ? – MikeSouto Jul 28 '17 at 12:12
  • The host must have the mongo extension for PHP installed and enabled, though. – M. Eriksson Jul 28 '17 at 12:13
  • @MikeSouto. I tested this code in my system and it is true. – ParisaN Jul 28 '17 at 12:21
  • @Magnus Eriksson. Are you sure? I unable mongo extension for my php but this code worked correctly :| – ParisaN Jul 28 '17 at 12:23
  • 1
    Yes, I'm sure. I just tried and it fails without that extension. Are you using Apache? If yes, did you disable it for cli or Apache and did you restart your Apache after disabling it? – M. Eriksson Jul 28 '17 at 12:26
  • Yes, You are true. it does't work without extension. But it should be show related error. No? – ParisaN Jul 28 '17 at 12:49

0 Answers0