Does not connect to the Database

I can not connect to the database. I assign constants:

constants.php

<?php
	define("DB_SERVER", "localhost");
	define("DB_USER", "SECRET");
	define("DB_PASS", "SECRET");
	define("DB_NAME", "SECRET");
?>

I create a separate file for connection:
includes/connection.php

<?php require("constants.php"); $con = mysql_connect(DB_SERVER,DB_USER, DB_PASS, DB_NAME) or die ('Ошибка подключения к базе данных'); ?>

After adding <?php include("includes/connection.php"); ?> in register.php, the page does not load.

What is the problem?

Maybe the credentials are wrong?
Add this to your htaccess

php_flag display_errors on

I dont have this file, so i created it.

And now my site does not work. Error:

Application error
An error occurred in the website and your page could not be displayed. If you are the website owner, check your logs for details.

After it is deleted, the site works again.

I decided to run with access to the database and now the user can successfully register. All because of the old version of the code for Php <7.

Help me now understand how to use htacces on this hosting.

Hi @SmeRT59!

Help me now understand how to use htacces on this hosting.

.htaccess is a file which configures how server should react on different situations per session. If it is configured incorrectly, 000webhost throws Application Error / 500.

@ckhawand told you to append that code to .htaccess in order to display the eventual PHP errors. It appears that you have inserted the code incorrectly, therefore you have received that error. The code supposed to be introduced in a new line. If the error was still occurring you should have used this code instead:

php_value display_errors 1

But now it does not matter anymore, as long as the problem has been solved :wink:

1 Like

No no no … Now I have a problem with this file and I want to know how it works) The problem is solved with connecting to the database. Do I create a better new topic?