How i can connect MongoDB online cloud in PHP - php

i want online connection with MongoDB cloud in PHP
same source file working properly when i run on localhost in my laptop with empty $server string while i use mongoDb server cloud then i face an error
<?php
session_start();
// $server="";
$server='mongodb+srv://mongo_user_1:<password>#mongodb01-dolny.mongodb.net/test?retryWrites=true&w=majority';
$mongo = new MongoClient($server);
$db=$mongo->blogPosting;
$admin_cl=$db->admin;
$category_cl=$db->category;
$blog_cl=$db->blog;
$contact_cl=$db->contact;
$blog_comment_cl=$db->blog_comment;
?>
Fatal error: Uncaught exception 'MongoConnectionException' with
message '- Found unknown connection string option 'retryWrites' with
value 'true'' in G:\xampp\htdocs\mongo_blog\mongoDb.php:5 Stack trace:
0 G:\xampp\htdocs\mongo_blog\mongoDb.php(5): MongoClient->__construct('mongodb+srv://m...') #1
G:\xampp\htdocs\mongo_blog\blog\index.php(1):
include('G:\xampp\htdocs...') #2 {main} thrown in
G:\xampp\htdocs\mongo_blog\mongoDb.php on line 5

Related

Mongodb Failed to look up SRV record

im new using mongodb,im trying to connect using php based on tutorial, im using ubuntu 20, i read mongodb default doesnt have user password and only accept 127.0.0.1. this script runs in same server as mongodb
<?php
require("vendor/autoload.php");
$client = new MongoDB\Client(
'mongodb+srv://127.0.0.1/test?w=majority'
);
$db = $client->test;
returns :
PHP Fatal error: Uncaught MongoDB\Driver\Exception\InvalidArgumentException: Failed to parse URI options: Failed to look up SRV record "_mongodb._tcp.127.0.0.1": The specified host is unknown. in /opt/wira/test_mongodb/vendor/mongodb/mongodb/src/Client.php:126
Stack trace:
#0 /opt/wira/test_mongodb/vendor/mongodb/mongodb/src/Client.php(126): MongoDB\Driver\Manager->__construct()
#1 /opt/wira/test_mongodb/test.php(5): MongoDB\Client->__construct()
#2 {main}
thrown in /opt/wira/test_mongodb/vendor/mongodb/mongodb/src/Client.php on line 126

PHRETS Works Locally But Times Out On Web Server

I installed PHRETS with Composer and have been able to print information using CMD terminal and following the docs. I tried uploading all the files to my web server, but the page times out.
My error log shows the following:
PHP Fatal error: Uncaught exception 'GuzzleHttp\Ring\Exception\ConnectException' with message 'cURL error 7: Failed to connect to rets-rald.realtyserver.com port 6103: Connection timed out' in /public_html/phrets/vendor/guzzlehttp/ringphp/src/Client/CurlFactory.php:126
Stack trace:
#0 /public_html/phrets/vendor/guzzlehttp/ringphp/src/Client/CurlFactory.php(91): GuzzleHttp\Ring\Client\CurlFactory::createErrorResponse(Array, Array, Array)
#1 /public_html/phrets/vendor/guzzlehttp/ringphp/src/Client/CurlHandler.php(96): GuzzleHttp\Ring\Client\CurlFactory::createResponse(Array, Array, Array, Array, Resource id #69)
#2 /public_html/phrets/vendor/guzzlehttp/ringphp/src/Client/CurlHandler.php(68): GuzzleHttp\Ring\Client\CurlHandler->_invokeAsArray(Array)
#3 /public_html/phrets/vendor/guzzlehttp/ringphp/src/Client/Middleware.php(54): GuzzleHttp\Ring\Client\CurlHandler->__invoke(Array)
#4 /public_html/phrets/vendor/guzzlehttp/ringphp/src/Client/Middlewa in /public_html/phrets/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 49
How can I get it working on the web server? Below is my configuration.
$config = new \PHRETS\Configuration;
$config->setLoginUrl('http://rets-rald.realtyserver.com:6103/saskatchewan/rets/login');
$config->setUsername('username');
$config->setPassword('password');
$config->setRetsVersion('1.5');
$config->setUserAgent('PHRETS/2.0');
$config->setHttpAuthenticationMethod('digest');
$config->setOption('use_post_method', false);
$config->setOption('disable_follow_location', false);
Turns out, I just needed to enable port 6103 on the server.

Fatal error: Uncaught exception 'MongoConnectionException' with message

I am testing the mongoDB in localhost and successfully installed the mongoDB in localhost. I have tried to connect the mongoDB using PHP in localhost.
It throws the error like 'Authentication failed'. It is successfully authenticated in cmd prompt.
Below is my code:
$username = 'testUser';
$password = 'testPassword';
$m = new MongoClient("mongodb://testUser:testPassword#localhost", array("db" => "testdb"));
Fatal error: Uncaught exception 'MongoConnectionException' with message 'Failed to connect to: localhost:27017: No connection could be made because the target machine actively refused it. ' in E:\xampp\htdocs\xampp\test.php:3 Stack trace: #0 E:\xampp\htdocs\xampp\test.php(3): MongoClient->__construct('localhost:27017', Array) #1 {main} thrown in E:\xampp\htdocs\xampp\test.php on line 3
I have also changed the localhost to ip(127.0.0.1) address but no use. Thanks in advance

Connect to Foxpro with PHP using OLE DB driver

I'm trying to connect to a Foxpro database using the OLE DB Driver
I downloaded the driver from http://www.microsoft.com/en-us/download/details.aspx?id=14839 and installed it then create a php script
$conn = new COM("ADODB.Connection") or die("Cannot start ADO");
$conn->Open("Provider=vfpoledb.1;Data Source=C:\Opera3\Comp_I.DBC;Collating Sequence=machine");
This gives me the following error
Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> ADODB.Connection<br/><b>Description:</b> Provider cannot be found. It may not be properly installed.' in C:\inetpub\wwwroot\test1.php:4 Stack trace: #0 C:\inetpub\wwwroot\test1.php(4): com->Open('Provider=vfpole...') #1 {main} thrown in C:\inetpub\wwwroot\test1.php on line 4
Any help in getting this working would be much appreciated.
As requested
uninstalled and reinstalled from command line as administrator for all users and now it works –

PDO Informix SQLDriverConnect: -"917"

i have big problem while connection to a remote informix database server.
here's the code
$db = new PDO("informix:host=192.168.*.*; service=1565;
database=daten; server=name; protocol=onsoctcp;
EnableScrollableCursors=1", "informix", "info00");
print "Connection Established!\n\n";
echo "Table contents: $rows.\n";
I receive the following error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE=HY000, SQLDriverConnect: -917 [Informix][Informix ODBC Driver][Informix]Must close current database before using a new database.' in /var/www/informix.php:9 Stack trace: #0 /var/www/informix.php(9): PDO->__construct('informix:host=1...', 'informix', 'info00') #1 {main} thrown in /var/www/informix.php on line 9
How can I fix this?
I think you should also set the DB_LOCALE environment variable.
When the client application requests a connection, it sends information, including the DB_LOCALE to the database server.

Categories