I imported the proper mongodb.dll file in php/ext and also configured php.ini but it seems that I can't connect to mongodb via my php code. Example
<?php
// connect to mongodb
$m = new MongoClient();
echo "Connection to database successfully";
// select a database
?>
Fatal error: Uncaught Error: Class 'MongoClient' not found in C:\xampp\htdocs\date\include\db2.php:3 Stack trace: #0 {main} thrown in C:\xampp\htdocs\date\include\db2.php on line 3
Related
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
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
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
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 –
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.