AlphaReign / www-php

The website of AlphaReign
56 stars 24 forks source link

Unable to setup registration #5

Closed crogers2287 closed 7 years ago

crogers2287 commented 7 years ago

Basic features are working, but I'm pulling my hair out trying to get registration to work so that I can use the API functions. The database is setup in mariadb, the info is set in index.php, but no matter what I do I just keep getting the "Oops! Looks like we ran into a little issue. Please try again later." when I try and create a user. Any ideas?

Raxvis commented 7 years ago

Have you turned debugging off?

crogers2287 commented 7 years ago

The only changes I made after I cloned the repo were the database changes to index.php. I'm not even sure how to turn it off/on to be honest.

Raxvis commented 7 years ago

In settings.php, change displayErrorDetails to true

crogers2287 commented 7 years ago

Is there somewhere else I'm supposed to be adding database details? The database is created, and the user is added to it. Sorry if it's something obvious I'm missing, I'm not real skilled with php.

Slim Application Error
The application could not run because of the following error:

Details

Type: PDOException
Message: Could not connect to database (ardb).
File: /var/www/lib/rb.php
Line: 857
Trace

#0 /var/www/lib/rb.php(683): RedBeanPHP\Driver\RPDO->connect()
#1 /var/www/lib/rb.php(881): RedBeanPHP\Driver\RPDO->runQuery('SELECT `user`.*...', Array)
#2 /var/www/lib/rb.php(3426): RedBeanPHP\Driver\RPDO->GetAll('SELECT `user`.*...', Array)
#3 /var/www/lib/rb.php(5136): RedBeanPHP\Adapter\DBAdapter->get('SELECT `user`.*...', Array)
#4 /var/www/lib/rb.php(7128): RedBeanPHP\QueryWriter\AQueryWriter->queryRecord('user', Array, ' WHERE username...', Array)
#5 /var/www/lib/rb.php(8201): RedBeanPHP\Repository->find('user', Array, 'username = ? LI...', Array)
#6 /var/www/lib/rb.php(8612): RedBeanPHP\OODB->find('user', Array, 'username = ? LI...', Array)
#7 /var/www/lib/rb.php(8657): RedBeanPHP\Finder->find('user', 'username = ? LI...', Array)
#8 /var/www/lib/rb.php(10781): RedBeanPHP\Finder->findOne('user', 'username = ? LI...', Array)
#9 /var/www/handlers/register.php(16): RedBeanPHP\Facade::findOne('user', 'username = ?', Array)
#10 /var/www/index.php(150): include('/var/www/handle...')
#11 [internal function]: Closure->{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#12 /var/www/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(41): call_user_func(Object(Closure), Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#13 /var/www/vendor/slim/slim/Slim/Route.php(344): Slim\Handlers\Strategies\RequestResponse->__invoke(Object(Closure), Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#14 /var/www/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(122): Slim\Route->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response))
#15 /var/www/vendor/slim/slim/Slim/Route.php(316): Slim\Route->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))
#16 /var/www/vendor/slim/slim/Slim/App.php(476): Slim\Route->run(Object(Slim\Http\Request), Object(Slim\Http\Response))
#17 /var/www/middleware/counts.php(23): Slim\App->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response))
#18 [internal function]: Closure->{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Slim\App))
#19 /var/www/vendor/slim/slim/Slim/DeferredCallable.php(43): call_user_func_array(Object(Closure), Array)
#20 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Slim\App))
#21 /var/www/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(73): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Slim\App))
#22 /var/www/middleware/es.php(11): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))
#23 [internal function]: Closure->{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#24 /var/www/vendor/slim/slim/Slim/DeferredCallable.php(43): call_user_func_array(Object(Closure), Array)
#25 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#26 /var/www/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(73): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#27 /var/www/middleware/auth.php(65): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))
#28 [internal function]: Closure->{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#29 /var/www/vendor/slim/slim/Slim/DeferredCallable.php(43): call_user_func_array(Object(Closure), Array)
#30 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#31 /var/www/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(73): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#32 /var/www/middleware/view.php(60): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))
#33 [internal function]: Closure->{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#34 /var/www/vendor/slim/slim/Slim/DeferredCallable.php(43): call_user_func_array(Object(Closure), Array)
#35 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#36 /var/www/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(73): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#37 /var/www/middleware/params.php(9): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))
#38 [internal function]: Closure->{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#39 /var/www/vendor/slim/slim/Slim/DeferredCallable.php(43): call_user_func_array(Object(Closure), Array)
#40 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#41 /var/www/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(73): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#42 /var/www/middleware/cookies.php(8): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))
#43 [internal function]: Closure->{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#44 /var/www/vendor/slim/slim/Slim/DeferredCallable.php(43): call_user_func_array(Object(Closure), Array)
#45 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#46 /var/www/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(73): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#47 /var/www/vendor/slim/csrf/src/Guard.php(162): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))
#48 [internal function]: Slim\Csrf\Guard->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#49 /var/www/vendor/slim/slim/Slim/DeferredCallable.php(43): call_user_func_array(Object(Slim\Csrf\Guard), Array)
#50 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#51 /var/www/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(73): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#52 /var/www/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(122): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))
#53 /var/www/vendor/slim/slim/Slim/App.php(370): Slim\App->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))
#54 /var/www/vendor/slim/slim/Slim/App.php(295): Slim\App->process(Object(Slim\Http\Request), Object(Slim\Http\Response))
#55 /var/www/index.php(159): Slim\App->run()
#56 {main}
Raxvis commented 7 years ago

Should be these lines right here in index.php

define('DBNAME', 'databasename');
define('DBUSER', 'databaseuser');
define('DBPASS', 'databasepass');
crogers2287 commented 7 years ago

Correct, those are all set to:

define('DBNAME', 'ardb'); define('DBUSER', 'ardb'); define('DBPASS', 'ardb');

Raxvis commented 7 years ago

Is it localhost?

crogers2287 commented 7 years ago

It is

Raxvis commented 7 years ago

Can you connect through the command line?

crogers2287 commented 7 years ago

I can

mysql -h localhost -u ardb -p ardb
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 46
Server version: 10.0.31-MariaDB-0ubuntu0.16.04.2 Ubuntu 16.04

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [ardb]> show databases;
+--------------------+
| Database           |
+--------------------+
| ardb               |
| information_schema |
+--------------------+
2 rows in set (0.00 sec)

MariaDB [ardb]>
Raxvis commented 7 years ago

they are both on the same machine?

Raxvis commented 7 years ago

make sure you install the mysql php pdo library

crogers2287 commented 7 years ago

It's installed and enabled in php.ini. Still getting the same error.

root@caddy:/etc/php/7.0/mods-available# ls calendar.ini fileinfo.ini json.ini opcache.ini phar.ini sockets.ini sysvshm.ini ctype.ini ftp.ini mbstring.ini pdo.ini posix.ini sqlite3.ini tokenizer.ini curl.ini gettext.ini mysqli.ini pdo_mysql.ini readline.ini sysvmsg.ini zip.ini exif.ini iconv.ini mysqlnd.ini pdo_sqlite.ini shmop.ini sysvsem.ini root@caddy:/etc/php/7.0/mods-available#

Raxvis commented 7 years ago

can you connect to another mysql server?

crogers2287 commented 7 years ago

Looks like enabling mysqli.ini pdo_mysql.ini in the php.ini file did the trick. I had forgotten to change the username and password back to ardb from something I was testing.

Thank you for all the help man. Hopefully this saves someone else from issues down the road.

Raxvis commented 7 years ago

Glad to hear you got it working