Mongodb-PHP app connection -


To add Mongodb with PHP application, I installed the Mozodb driver in Windows and the extension was enabled (phpinfo ()). Then I execute the kootpi php code

  & lt ;? Php // Config $ dbhost = 'localhost'; $ Dbname = 'test'; // Connect to test database $ m = new Mongo ("mongodb: // $ dbhost"); $ db = $ m- & gt; $ dbname; // archive $ collection = $ db- & gt; Select Show; // Drag a cursor query $ cursor = $ collection-> Search (); Foreign exchange ($ cursor $ document) {var_dump ($ document); }? & Gt;   

And this gives a serious error how can this solve it? Fatal error: 'Failed to connect with' MongoConnectionException 'message with unsolicited exception: Local Host: 27017: No connection can be made because the target machine is actively denied. In C: \ xampp \ htdocs \ check \ index.php: 7 stack trace: # 0C: \ xampp \ htdocs \ check \ index.php (7): Mongo Client-> __Construct ('Mongodb: // local.') # 1 {main} put in C: \ xampp \ htdocs \ check \ index.php on line 7 < P>

Check that this connection and test wode is working whether it is working in your system:

  lt ;? Php $ m = New Mongo Client ("Localhost"); $ dbname = $ m- & gt; Selection DB ("Test"); $ Collection = $ dbname- & gt; Select All ("Shows"); $ data1 = array ('user_id' = & gt; ABC ',' age '=> 20,' position '=>' A '); $ dbname = $ Collection-> Insert ($ data1, array ('$ data1' = & gt; 1)); $ Result = $ collection-> Search (); Echo "& lt; east & gt;"; Foreign Currency ($ result as $ test) {print_r ($ test); Echo "& lt; / pre>"; ? & Gt;    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -