Answer the question
In order to leave comments, you need to log in
Can't query MySQL database?
Good afternoon, faced such problem. I am using the mysqli_qeury function, but it does not see the variable assigned to the database connection function. The connection to the database itself works, but the request does not go.
Code from dbconect.php
<?php
// Подключение к БД
$myHostName = "localhost";
$myUserName = "root";
$myPassword = "";
$myDataBase = "";
$dbconnect = mysqli_connect($myHostName,$myUserName,$myPassword,$myDataBase);
// Проверка подключения к БД
if ($dbconnect == true) {
echo "<pre>";
echo "Успешное подключение к БД";
echo "<pre>";
}
else{
echo "<pre>";
exit ("Ошибка подключения к БД");
echo "<pre>";
mysqli_close($dbconnect);
}
?>
<?php
session_start();
require "dbconect.php";
// Данные регистрации
$first_name = $_POST["first_name"];
$last_name = $_POST["last_name"];
$email = $_POST["email"];
$password = $_POST["password"];
$password_confirm = $_POST["password_confirm"];
$captcha = $_POST["captcha"];
// Проверка паролей и капчи
if (($password == $password_confirm) and ($captcha == $_SESSION["rand"])) {
header("Location: ../www/form_auto.php");
} else {
$_SESSION["msg"] = "Пароли не совпадают";
header("Location: ../www/form_register.php");
}
mysqli_query($dbconnect, INSERT INTO `users` (`id`, `first_name`, `last_name`, `email`, `password`) VALUES (NULL, NULL, NULL, NULL, NULL));
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question