-3

Tell me pls, Why does the project moving to VPS fall into error 500 for any request to the DB? Prior to this, the project was on a regular hosting and worked without problems.

apache logs

[Mon Sep 14 14:19:43.031257 2020] [php7:notice] [pid 25463] [client 77.93.52.193:46222] PHP Notice: Undefined index: logged_user in /var/www/project/includes/model.php on line 11

[Mon Sep 14 14:19:43.031654 2020] [php7:notice] [pid 25463] [client 77.93.52.193:46222] PHP Notice: Trying to get property 'id' of non-object in /var/www/project/includes/model.php on line 11

[Mon Sep 14 14:19:43.033118 2020] [php7:error] [pid 25463] [client 77.93.52.193:46222] PHP Fatal error: Uncaught [3D000] - SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected\ntrace: #0 /var/www/project/includes/redbean-orm.php(882): RedBeanPHP\Driver\RPDO->runQuery('SELECT users....', Array)\n#1 /var/www/linkmarky/includes/redbean-orm.php (3466): RedBeanPHP\Driver\RPDO->GetAll('SELECT users....', Array)\n#2 /var/www/linkmarky/includes/redbean-orm.php(5177): RedBeanPHP\Adapter\DBAdapter->get('SELECT users, Array)\n#3 /var/www/linkmarky/includes/redbean-orm.php(7172): RedBeanPHP\QueryWriter\AQueryWriter->queryRecord('users', Array, ' WHERE id = ? L...', Array)\n#4 var/www/project/includes/redbean-orm.php(8255): RedBeanPHP\Repository->find('users', Array, 'id = ? LIMIT 1 ', Array)\n#5 /var/www/project/includes/redbean-orm.php(8665): RedBeanPHP ... /var/www/project/includes/redbean-orm.php(10854): RedBeanPHP\Finder->findOne('u in /var/www/project/includes/redbean-orm.php on line 720

code part

databases

  • 500 Internal Server Error is a generic error message informing you that the server crashed while processing the request. Beyond that, it's meaningless, and is of very little use for debugging. You need to check the error logs on the server to try and find the underlying exception message. Once you've got that, you stand a chance of identifying the problem. – ADyson Sep 14 '20 at 11:27
  • I attach error logs screen. First screen – gitarasanya Sep 14 '20 at 11:29
  • 2
    It looks like your first screenshot _might_ be that error, but it's cut off half-way through so we can't be sure. Please post the full error message, as **text** - pictures of code and errors are not helpful (see [How To Ask](https://stackoverflow.com/help/how-to-ask) and [this link](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question/285557#285557) for the guidance showing why this is annoying for people trying to help you). Also please take the [tour](https://stackoverflow.com/tour) that you were asked to when creating your account :-) – ADyson Sep 14 '20 at 11:29
  • @ADyson I displayed the all message in text. – gitarasanya Sep 14 '20 at 11:37
  • [“Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP](https://stackoverflow.com/questions/4261133/notice-undefined-variable-notice-undefined-index-and-notice-undefined) – aynber Sep 14 '20 at 11:39
  • The answer below seems to cover your scenario. Possibly in your previous environment there was some sort of default database selection configured. Either that or you've changed the connection string for your new environment and failed to add the dbname setting back in. You should probably also try and fix the undefined index notices as well, but they're a separate problem. – ADyson Sep 14 '20 at 11:45

1 Answers1

1

The cut-off error seems to be, that there is no database selected.

Looking at RedBeanPHP documentation: Connection docs It looks like you've made a mistake with your connection string. The connection string should look like this (mind the dbname=):

 R::setup( 'mysql:host=localhost;dbname=mydatabase',
        'user', 'password' ); //for both mysql or mariaDB