I need your help. I'm making a project for my thesis and I'm trying to fix this problem for a week without any results. I know that there are a lot of similar topics but I can swear that I didn't find nothing cocern my problem.
I have a web domain on "register.it" where my website has supposed to be. My website need to communicate and handle data from mongo database. So, I have also a remote server (with Ubuntu 16.04) where I install everything correctly (I followed an online guide and tested everything). In fact, locally (I mean, with the mongo shell), there aren't any problem. If I use "systemctl status mongod" it is active. These are other features of the environment:
php 7.0.30
mongodb 3.4.16
mongodb driver 1.5.1
mongodb database driver 1.6.16
Of course, I also added the extension in the "php.ini" file and allowed the connection from anywhere to the port 27017.
My simple page php have this code:
$mongo = new MongoClient('mongodb://user_of_db_admin:passwd_of_db_admin#151.236.61.166:27017/admin');
echo "Connection to database successfull."
But it doesn't print anything. If I write only the echo, obviously, it will show the text. And if I write this code instead of the echo:
$dbs = $mongo->listDBs();
print_r($dbs);
the page will show this text "listDbs(); print_r($dbs);".
In others questions the users complaining because the page showed an error about the connection mongo function (or at least some error message), but I receive only text or a blank page.
I hope you could help me. If there are others information that you need, tell me and I will update my post.
Related
Good day,
I am using wampserver, and I would like to get data from a remote IBM database (AS400) using db2_connect. I've tried searching on some ways but I couldn't get the idea of doing it. I have successfully included ibm_db2.dll extension on my php. However, I don't know what to do next.
As you seem to be using "DB2 Connect" (and not a separate DB2 client) product you can either configure DB2-Connect with a node/alias/dsn and then mention that alias with the db2_connect() action, or use PDO_IBM longer connection string with all the details as mentioned here.
You need to know the tcpip-address (or hostname) of the i-Series DB2-server, and the Port-number it listens on.
Check this technote for the actions required to make a node/alias (I believe the same general configuration pattern applies to DB2-connect as Data server client).
The advantage of configuring like this is that you can verify the database-connect in your workstation command line shell , before making it work in PHP/pdo.
Introduction
For the past couple of days I’ve been messing about with PHP web sockets, in an attempt to retrieve some information in real-time for the user about the various different people connected.
I’m on Ubuntu, running the latest version of XAMPP (located under /opt/lampp/), the web socket I run using PHP which I’ve installed using apt-get install php. This opens a socket with no problem whatsoever.
The problem I’m facing has to do with establishing a connection to the database from the web socket with a little help from PDO. Whenever I attempt to establish the connection to the database located on localhost, I get the following error message:
SQLSTATE[HY000] [2002] No such file or directory
Since PHP and my MySQL server isn’t aware of one another, considering MySQL is run through the instance of XAMPP and the server is run using the version of PHP (which is the same as the one as for XAMPP) I’ve installed using apt-get, one might think that this is the cause of problems. But shouldn’t the server be reachable as long as you have the correct username and password to the server configuration?
Research
I’ve been doing quite some research on the subject, and have found multiple potential solutions for the problem, but neither one appears to do the job. For example, on this question, it is suggested that you can solve this error by doing some witchery to your server software, as well as PHP—I’ve tried this with to apparent success.
On other questions, it’s instead suggested that you change this DSN PDO setup:
$dsn = "mysql:host=$host;port=$port;dbname=$name;charset=$charset";
To instead of using "localhost" for the host, you stick with 127.0.0.1—as a matter of fact, I can’t even connect unto my server if I were to do this. Doing this, my XAMPP gets stuck in some form of endless loop. A minute or so after changing from 127.0.0.1, back to localhost, it starts working again.
I can’t remember where, but I also remember seeing somebody saying it’s not at all doable (connecting to MySQL from a PHP socket), which I’d find extremely strange.
Some people also seem to suggest switching to Node.js for handling real-time connections, but I’d very much like to keep it all PHP if possible.
Furthermore
I’m probably just being a complete moron (I was ;-)), but if anybody can point me in the right direction it would be highly appreciated!
you need to specify the path of the socket
example:
$dsn = 'mysql:dbname=testdb;unix_socket=/path/to/socket';
Try to search the file mysql.sock inside the /opt/lamp
OpenSuse Leap 42.1 (latest upgrade)
Apache2, PHP 5.5 installed
OCI8 installed
ORACLE 11g
Last week, I got some update issues with KDE and did an upgrade of OpenSuse Leap 42.1. I then went over the whole procedure of installing oci8 (as described in http://php.net/manual/en/oci8.installation.php and making sure to use the correct PECL) and everything worked fine.
But when I restarted my system a few hours later, I was't able to connect via hhtp to any vhost due to failed connection to the database.
I get no error logs anywhere, just a white 404 page or the message "Error: Could not connect to database. Aborting." (depending on which page I'm calling). Pages with no connection to the database work perfect!
SQLDeveloper connects without any proble, using the same parameters as in the config-files for the vhosts.
Anyone any idea?
Generally when you get a
ORA-12514
it means that the listenr you are connecting to knows not the servicename/SID you're attempting to connect to. If you get that error it should indicate that the client got some sort of response from the listener which should exclude all sorts of network issues.
This is very much similar to ORA-12514 TNS:listener does not currently know of service requested in connect descriptor
only that the issue sprouted up after an update.
I would first look in the client side tnsnames.ora and the server side listener.ora to check that everything is ok. Also check that the database is registered on the listener. Possibly also check that the db is remotely reachable from a known good client to exclude any issues on the listener configuration.
problem(s) solved!
as there were two different of them provoking a problem salad.
first, the update somehow managed to change some parameters in my config files, first of all the database name.
then, apache update from 2.2 to 2.4 DID change some things in the vhosts config files and therefore the errors were never logged in the former x_error.log and the 404 message was shown.
thx a lot for your response, louigi600!
I am trying to connect to a MS Access Db that I have made from my apache server using PHP. I keep coming up with the error "could not find driver". I have searched through just about every web page on the internet and have found nothing of importance. I have undocumented the parts of the php.ini file to allow the odbc drivers to work. I also have tried to list all of the working drivers using the PDO::getAvailableDrivers() code yet nothing shows up no matter how many drivers I undocument from the php.ini file. I've created the DNS connection and linked it to the database yet I'm not sure how to connect to it.
Any help would be greatly appreciated.
For everyone else that needs an answer to this:
MS Access has stopped updating and hosting their odbc connection to php in 2010 (approximately). It will still work if you make sure you're using a 32-bit system. I'm now using 32-bit Apache and PHP. It works flawlessly now.
Is there a way to establish a connection to a cloud mongoDB (such as mongoHQ), with no drivers or third party apps, from a localhost server?
In other words, I want to host my php files locally, and connect to a mongoDB on the cloud.
I've been doing simple websites using php and MySQL as a hobbie for a few years, and I'm pretty decent at it, but I haven't been able to figure out how to do this one simple thing with Mongo.
Whenever I run a file that does:
$m = new Mongo('mongodb://username:password#staff.mongohq.com:XXXXX/database');
from a php file, I get a HTTP 500 error.
Any help would be greatly appreciated. In advance I apologize if this isn't clear enough, this is my first post on SO. Please let me know if more info is needed.
Have you looked at your PHP/apache error log to see what the HTTP 500 error is ? Try adding to the top of your script:
ini_set('display_errors',1);
error_reporting(E_ALL);
Based on your code sample, I would check that you have the Mongo module installed as it will generally not be included by default. Use phpinfo() and look for the mongo section.
If you want to use MongoHQ without installing a Mongo driver, you could also try their REST API which apparently is still in beta phase.