I am a beginner to mongoDB, I want to learn mongoDB. So I read few tutorials and tried to configure mongoDB in my local machine, for that I have downloaded mondoDB's php_mongo.dll file and placed that on my local machine into the path "php/ext/php_mongo.dll" and after that I added this code "extension = php_mongo.dll" to php.ini file, after that I am trying run my XAMPP server but immediately it is showing the below error :
C:xampp\php\ext\php_mongo.dll is either not designed to run on Windows
or it contains an error. Try installing the program again using the
original installation media or contact your system administrator or
the software vendor for support.
after that somehow Apache server has been started And when I try to run the application on browser by URL http://localhost/mongoapp/index.php then it is throwing the following error:
Fatal error: Uncaught Error: Class 'MongoClient' not found in C:\xampp\htdocs\mongoapp\index.php:3 Stack trace: #0 {main} thrown in C:\xampp\htdocs\mongoapp\index.php on line 3
File: index.php
// connect to mongodb
$m = new MongoClient();
echo "Connection to database successfully";
// select a database
$db = $m->mydb;
echo "Database mydb selected";
My php version is "PHP Version 7.0.8". hope someone helps, Thanks in advance.
Check your phpinfo if mongodb is loaded.
Download mongodb from "https://www.mongodb.com/download-center?jmp=nav#community" and install.
Check your architecture in phpinfo match with mongodb.
Related
I installed xampp on my local computer. The data in the project is stored in memory, but the memcached function did not work on my local machine.
$memcache=memcache_connect('127.0.0.1', 11211);
Error code:
Fatal error: Call to undefined function memcache_connect() in
I called the error, but the solutions didn't work for me.
Suggested solutions include the addition of new services
I am getting this error when adding new service
"failed to install service or service already installed"
**Windows 7
**Xampp
**Apache/2.4.34 (Win32) OpenSSL/1.0.2o PHP/5.6.38
I'm running PHP 7.1 on an IIS 10.0 server and trying to connect to a MSSQL database.
Trying to instantiate a connection like this:
$dbh = new PDO("sqlsrv:Server=#server#;Database=#dbname#", "#username#", "#passwd#");
Gives me this error:
Fatal error: Uncaught PDOException: could not find driver in C:\inetpub\wwwroot\projects\test.php:6 Stack trace: #0 C:\inetpub\wwwroot\projects\test.php(6): PDO->__construct('sqlsrv:Server=...', '#username', '#pwd...') #1 {main} thrown in C:\inetpub\wwwroot\projects\test.php on line 6
However, sqlsrv is activated in my php.ini:
extension=php_sqlsrv.dll
extension=php_pdo_sqlsrv.dll
It's uncommented, and it's the right php.ini (already checked with phpinfo()). Restarting the server also didn't do anything.
I really don't understand why this is happening when the driver is obviously installed :/
What makes it extra weird is that I have another application running on the same server that also connects to a MSSQL database and it works with no problems, it had an automatic installer though so I didn't have to configure anything myself. It also connects to a local db and right now I'm trying to connect to a remote one if that makes a difference.
I want to access to a SQL Anywhere database which is on another server.
I can do it easily from Windows, but I need to do it from Debian now.
All of this in php.
Windows side :
I have installed SQL anywhere driver from https://archive.sap.com/documents/docs/DOC-35857, and connect with odbc:Driver={SQL Anywhere 16};Server=serveur-02;Port=2638;Database=excalib;Uid=username;Pwd=pwd;
Ok, it works.
Debian side :
I am on Debian 9 with php 7.0.
UnixODBC is already installed and works with some others connections.
FreeTDS is installed too.
So I have make a link in odbcinst.ini :
[SQLAnywhere16]
Description = SQLAnywhere driver
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
And in odbc.ini :
[Excalibur]
Description = Excalibur
Driver = SQLAnywhere16
Server = [ip]
Port = 2638
Name = excalib
User = user
Password = password
With command
isql -v Excalibur
I got
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[08004][unixODBC][FreeTDS][SQL Server]Erreur SQL Anywhere -83 : La base de
donn▒es sp▒cifi▒e est introuvable
[ISQL]ERROR: Could not SQLConnect
As I understand, it reaches server, but don't find my database. Ok, it's encouraging. Maybe a typo mistake, but I can't find documentation which can tell me, maybe someone has a hint ?
Next step is to do it with php.
odbc:Driver={SQLAnywhere16};Server=[ip];Port=2638;Database=excalib;Uid=user;Pwd=pwd
And... it does nothing. I got nothing from my server (ERR_EMPTY_RESPONSE)
There's nothing in apache's log.
If I do a typo mistake on purpose on the driver path, it sends a correct error
Fatal error: Uncaught PDOException: SQLSTATE[01000] SQLDriverConnect: 0 [unixODBC][Driver Manager]Can't open lib '/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so1' : file not found in /var/www/html/test.php:24 Stack trace: #0 /var/www/html/test.php(24): PDO->__construct('odbc:Driver={SQ...') #1 {main} thrown in /var/www/html/test.php on line 24
And... I'm lost. Someone can help me ? Or maybe has another solution to connect to SQLAnywhere database ?
Thank you.
Edit [thank to Nitrex] :
When I try to connect via php, tcpdump doesn't capture anything, so I think the problem come from Debian side.
I am trying to run mongodb code with the following system configuration:
Operating System: Windows 7 (32 bit)
PHP Version: 5.2.9 Apache
Version: Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i
PHP/5.2.9
I am using XAMPP in my system.
What I did to configure mongodb with the xampp is below:
I went to https://github.com/mongodb/mongo-php-driver/downloads and download the first link (php_mongo-1.3.2RC1.zip) zip.
After unzipping the file I copied php_mongo-1.3.2RC1-5.2-vc9.dll DLL file in xampp/php/ext/ directory in my xampp installed directory
Then add extension=php_mongo-1.3.2RC1-5.2-vc9.dll in the php.ini file
Restarted xampp server
Then I saw the xampp phpinfo() and it is displaying that mongodb is installed. Please follow the image below from my phpinfo() page
Now I wrote a sample code for using mongodb as below:
<?php
$m = new Mongo();
$db = $m->learningmongo;
$people = $db->people;
?>
and it is displaying the Fetal error on screen as below:
Fatal error: Uncaught exception 'MongoConnectionException' with message 'Failed to connect to: localhost:27017: Unknown error' in E:\xampp\htdocs\mongo\index.php:3 Stack trace: #0 E:\xampp\htdocs\mongo\index.php(3): Mongo->__construct() #1 {main} thrown in E:\xampp\htdocs\mongo\index.php on line 3
Where I am doing wrong, please guide me. Any code sample and web link would be highly appreciated.
Can anybody please let me know, i have used the below code to access COM object...
$zip = new COM("Chilkat.Zip2");
echo $zip;
but, which shows an like this...
Fatal error: Uncaught exception 'com_exception' with message 'Failed
to create COM object `ZipActiveX': Invalid syntax ' in
D:\xampp\htdocs\test\testscript1.php:2 Stack trace: #0 D:\xampp\htdocs\test\testscript1.php(2): com->com('ZipActiveX')
#1 {main} thrown in D:\xampp\htdocs\test\testscript1.php on line 1
please advice me, that do i need to change anything in my php.ini file to access COM?
shut down apache and start in administrator mode if using windows vista or 7.
edited:
chillkat zip activex is for windows server. you can download and install from this url http://www.chilkatsoft.com/download/ZipActiveX.msi
run webserver in windows using xampp adn run locally
xampp download url: http://www.apachefriends.org/en/xampp.html