Adding .env file to UserFrosting - php

I am facing a problem linking my MySQL database to Userfrosting. The guide gives an example of adding a .enr file to the directory so that Userfrosting can read the database credentials, but it doesn't seem to work.
Can someone give me an in-depth tutorial on how to do it?
Here is the error code when running install.php:
Could not connect to the database '#/'. Please check your database
configuration and/or google the exception shown below:
Exception: SQLSTATE[HY000] [2002] No such file or directory
Trace:
#0 /Applications/XAMPP/xamppfiles/htdocs/myUserFrostingProject/migrations/install.php(63): PDO->__construct('mysql:host=;dbn...', NULL, NULL)
#1 {main}

For MAMP, the DB_HOST needs to be set to 127.0.0.1 instead of localhost. It's probably the same case with XAMPP. There's already an open pull request regarding this. See https://github.com/userfrosting/UserFrosting/pull/659.

Related

Where to save AWS Credentials file when using shared hosting?

I'm using Amazon's AWS PHP SDK and I installed composer on the following directory 'public_html/composer'. I am currently using shared hosting. However, I have access to the root.
When I tried using AWS's sample code I'm getting the following errors in my error_log:
Fatal error: Uncaught Aws\Exception\CredentialsException: Cannot read credentials from /.aws/credentials in /home2/maltaboo/public_html/composer/vendor/aws/aws-sdk-php/src/Credentials/CredentialProvider.php:691 Stack trace: #0 /home2/maltaboo/public_html/composer/vendor/aws/aws-sdk-php/src/Credentials/CredentialProvider.php(424): Aws\Credentials\CredentialProvider::reject('Cannot read cre...') #1 /home2/maltaboo/public_html/composer/vendor/aws/aws-sdk-php/src/Middleware.php(121): Aws\Credentials\CredentialProvider::Aws\Credentials\{closure}() #2 /home2/maltaboo/public_html/composer/vendor/aws/aws-sdk-php/src/RetryMiddleware.php(266): Aws\Middleware::Aws\{closure}(Object(Aws\Command), Object(GuzzleHttp\Psr7\Request)) #3 /home2/maltaboo/public_html/composer/vendor/aws/aws-sdk-php/src/Middleware.php(206): Aws\RetryMiddleware->__invoke(Object(Aws\Command), Object(GuzzleHttp\Psr7\Request)) #4 /home2/maltaboo/public_html/composer/vendor/aws/aws-sdk-php/src/StreamRequestPayloadMiddleware.php(83): Aws\Middleware::Aws\{closure}(Ob in /home2/maltaboo/public_html/composer/vendor/aws/aws-sdk-php/src/Credentials/CredentialProvider.php on line 691
I created my credentials files as per AWS tutorial:
[default]
aws_access_key_id = 123456789
aws_secret_access_key = abcdefghijklm
The documentation states that I must save it in this location: ~/.aws/credentials
I tried many times to create the directory .aws/credentials however I get the same error. I tried also looking for the .aws file but I couldn't locate it except the one that I just created.
Given the above where should I place the credentials file? TIA
I also had the same issue of cannot read /.aws/credentials
Mentioning my solution here for reference:
This solution is tested in aws-php-sdk version 3.173:
CredentialProvider.php uses getenv('HOME')/.aws/credentials path to load the credentials from the file.
In my case (linux shared hosting) it was empty.
So I set it to desired value using:
putenv("HOME=/absolute/path/to/folder/containing/.aws/folder")

PHP site running fine on localhost but not working on a live server

My PHP site not working on an apache server.It is working fine on localhost but after uploading on the server it showing me the blank pages.Here is my error log file
[28-Feb-2018 04:43:16 America/New_York] PHP Fatal error: Uncaught exception 'mysqli_sql_exception' with message 'Table 'combejcj_waqar-accounts.addsupplier' doesn't exist' in /home/combejcj/waqar.combitpos.com/waqar/public/home.php:24
Stack trace:
#0 /home/combejcj/waqar.combitpos.com/waqar/public/home.php(24): mysqli_query(Object(mysqli), 'SELECT fullname...')
#1 {main}
thrown in /home/combejcj/waqar.combitpos.com/waqar/public/home.php on line 24
Considering the error message it says that there is no table with the name combejcj_waqar-accounts.addsupplier
So, there can be 2 problems:
1) You forgot to upload your DB table
2) You are on a Linux environment which means that you are in a Case sensitive enviroment and in your code you are doing e.g. an insert on combejcj_waqar-accounts.addsupplier but the table name is with Capital First letters for example combejcj_waqar-Accounts.Addsupplier
So, make sure that the table name on the server is exactly the same with the one you are using into your code.
The error is telling you what the problem is. It's saying that your MySQL table combejcj_waqar-accounts.addsupplier doesn't exist. Did you migrate the MySQL database when you changed over to the server?
Table does not exist in the database.
You have 2 possible solutions
- Export the local database and import it on the live server.
- Create the table on the live server.

PHP connect to MS Access database - Provider not found

I know there are tons of questions about this on SO. But I've been trying to fix this since a month with no luck.
At work we have this very old website that uses an access database, and I cannot do anything about it.I want to work on some changes on my local PC using wamp server. So I donwloaded the website along with the db. Here is how it's supposed to connect :
$conn = new COM('ADODB.Connection');
$db = realpath("dbalerts.mdb");
$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$db");
But it's giving me this error:
Fatal error: Uncaught exception 'com_exception' with message 'Source: ADODB.Connection
Description:Provider cannot be found. It may not be properly installed.'
in C:\wamp\www\testaccess\index.php:5 Stack trace: #0 C:\wamp\www\testaccess\index.php(5): com->Open('Provider=Micros...') #1 {main} thrown in C:\wamp\www\testaccess\index.php on line 5
It's a test folder whith an index.php where only that code is written. In the same folder is dbalerts.mdb
I tried everything I know. I downloaded AccessDatabaseEngine.exe from MS website which is supposed to have the driver. And it installed properly with no errors( had to uninstall office because it was 64bit)
I am on a win8 machine
Any ideas how I can fix this all while still using COM and ADODB? Because I can't go through changing the connections of every .php file in that website (it's old and poorly designed so not adaptable to changes)

Mirror API database access issue

I just installed the Google mirror API. I have everything setup except after I log in to the API, I get this error message:
Notice: A session had already been started - ignoring session_start() in C:\xampp\htdocs\mirror-client.php on line 33
Fatal error: Uncaught exception 'Exception' with message 'Unable to open database: unable to open database file' in C:\xampp\htdocs\util.php:62 Stack trace: #0 C:\xampp\htdocs\util.php(62): SQLite3->__construct('/tmp/database.s...') #1 C:\xampp\htdocs\util.php(26): init_db() #2 C:\xampp\htdocs\oauth2callback.php(41): store_credentials('107736579479351...', '{"access_token"...') #3 {main} thrown in C:\xampp\htdocs\util.php on line 62
It seems that the API can't create the database or do I need to create it?
I tried making a folder and database as it is set up in the config.php file "tmp/database.sqlite" but no luck.
Any ideas?
I figured out that you had to make your own database for it to work.
It can mean that the directory/folder you placed the sqlite file in (and the file itself) does not have the correct permissions. You need to make sure both the folder and the file have read and write permissions. The xampp directory in my environment has read/write permissions. You might want to place your database there, at least for testing purposes.
Note: The /tmp directory as mentioned in "/tmp/database.sqlite" is a Linux/Mac directory. You may want to change the value of $sqlite_database in the config.php file to point to a file in a Windows directory.

Cassandra PDO connection PHP

I've got Cassandra working nicely on Debian server however I'm hoping to connect to it from a PHP application.
Currently it seems PDO it the way to go for anything complex as I'm able to use CQL. I'm using the latest forked version of the Apache Cassandra-PDO project.
I'm using the latest Cassandra 2.03 and I can connect to it fine from CQLSH in the terminal.
When I try and connect in PHP using the following code
$db_handle = new PDO("cassandra:host=localhost;port=9160");
I get the following error
Fatal error: Uncaught exception 'PDOException' with message 'CQLSTATE[08006] [8] TTransportException: Transport not open' in /var/www/index.php:9 Stack trace: #0 /var/www/index.php(9): PDO->__construct('cassandra:host=...') #1 {main} thrown in /var/www/index.php on line 9
I've seem a few issues alike on the internet, but no solutions as yet. Hopefully someone can provide some insight into the issue here.
Error 8006 is connection failure. I think you need login and password in PDO Statment like this:
$pdo = new PDO('mysql:host=localhost;dbname=products', 'root', 'root');
Try running 'nodetool status' from the cli to verify the IP address the server is running on.
Then perhaps change localhost to 127.0.0.1 if instead the local host.

Categories