N
N
neti_solo2018-07-12 08:13:42
PHP
neti_solo, 2018-07-12 08:13:42

Redbean is not connecting, what should I do?

Hello, here is such a thing, on my local server ( openserver ) the connection of the redbean library worked fine, as well as its functionality, however, after transferring the files on the server, everything stopped working ... By endless echo, I found out that the matter was in the included file, which carries the functions of connecting the library file ( rb.php ) and connecting to the database, and so, see the code below:

<?php 
echo "Test1";

require "rb.php";

echo "Test2";

R::setup( 'mysql:host=avtoasia.mysql;dbname=avtoasia_test2',
        'avtoasia_test2', 'Kd34(df2' ); //for both mysql or mariaDB

echo "Test3";

var_dump(R::queryAll('SELECT * FROM table'));

echo "Test4";
?>

Only 1,2,3 - Test is displayed, but 4 is no longer there (
I thought it might be the file itself, the wrong directory and the library is not connected, but no. If you remove require, it only displays 1,2 - Test ... From which it follows that then the connection to the database does not work anymore due to the lack of a library.So, as you can easily guess, it is in the connection to the database (or maybe not, please check the code, maybe it's something else ??? ) Login, password, database - everything is 100% correct in them, it was checked a thousand times, but maybe I don’t have the correct host, I inserted the same one that I entered into the normal mysqli_connect database connection, it works there, which means is it probably correct too? In general, all data is identical, both from a normal connection and from redBean, but a normal connection works, but redbin does not (((
In general, I’m asking for help... Wherever you connect this file, it doesn’t work... For every firefighter, the code from the page where this ORM is used is even lower (there only outputs '1233Test1Test2Test3' ), but the outputs already in the file do not work, whose code is above :(
<?php
session_start();
echo "1233";
require 'php/db.php';
echo "string";
$data = $_POST;
echo "string";
$errors = array();
echo "string";
if ( trim($data["names"] == "") || trim($data["names"] == " ") ) {
  $errors[] = "Вы не ввели имя, код ошибки #01";
}

if ( trim($data["surname"] == "") || trim($data["surname"] == " ") ) {
  $errors[] = "Вы не ввели фамилию, код ошибки #02";
}

if ( trim($data["email"] == "") || trim($data["email"] == " ") ) {
  $errors[] = "Вы не ввели электронную почту, код ошибки #03";
}

if ( !strpos( $data["email"], "@" ) ) {
  $errors[] = "Это не эелектронная почта, код ошибки #031";
}

if ( trim($data["phone"] == "") || trim($data["phone"] == " ") ) {
  $errors[] = "Вы не ввели номер телефона, код ошибки #04";
}

if ( mb_strlen( trim($data["phone"]) ) != "11" ) {
  $errors[] = "Это не телефон, код ошибки #041";
}

if ( trim($data["login"] == "") || trim($data["login"] == " ") ) {
  $errors[] = "Вы не ввели логин, код ошибки #05";
}

if ( trim($data["password"] == "") ||  trim($data["password"] == " ") ) {
  $errors[] = "Вы не ввели пароль или ваш пароль состоит только из пробелов, код ошибки #06";
}

if ( R::count('users', "login = ? OR email = ?", array($data["login"], $data["email"])) > 0 ) {
  $errors[] = "Пользователь с таким логином или электронной почтой уже существует, код ошибки #07";
}

print_r( $errors );

if ( empty( $errors ) ) {
  
  $user = R::dispense("users");

  $user->names = $data["names"];
  $user->surname = $data["surname"];
  $user->email = $data["email"];
  $user->phone = $data["phone"];
  $user->login = $data["login"];
  $user->city = $data["city"];
  $user->password = password_hash($data["password"], PASSWORD_DEFAULT);
  $user->history = "YTowOnt9";
  $user->favorite = "YTowOnt9";

  R::store($user);

  header("Location: index.php");
  exit;

} else{
  echo "<p style=\"color: red;\">" . array_shift($errors) . "</p><hr>";
}


?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2018-07-12
@Stalker_RED

... Through endless echoes, I found out ...
... the site is hosted, the customer does not give access ...

The best option is to explain to the customer why you need error.log . You
can also set your own php set_error_handler and set_exception_handler at the entry point, and write your own log, or display errors (and stack trace!) On the screen.
If that doesn't work - RUN!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question