php - Mongodb connectivity error -


<?php /**  * connects mongodb server.  * stops code execution on`enter code here` connection error.  *  * not need use file, place globally assign mongodb instance $db.  *  * define constants in config or here  */   define('mdb_username', 'root');  define('mdb_password', 'asd');  define('mdb_host', 'localhost:80');  define('mdb_name', 'abc');   if (!class_exists('mongo')) {     die("mongo class not existing. did install php mongodb extension?"); }  try {     $conn = new mongoclient("mongodb://".mdb_username.":".mdb_password."@".mdb_host."/".mdb_name);     $conn->authenticate('root','gynadfehurbo');     $db = $conn->selectdb(mdb_name); } catch (mongoconnectionexception $e) {     die($e->getmessage()); // in production might want turn off. } 

mongodb connectivity problem.

while trying connect mongodb php got authentication problem ..by giving port above error replaced connection refused .then changed port error has been replaced

failed connect to: localhost:80: read timed out after reading 0 bytes, waited 60.000000 seconds

 $server = "mongodb://localhost:27017/dbname";   // connecting server  $c = new mongoclient($server );     if($c->connected)          echo "connected successfully";   else           echo "connection failed"; 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -