Answer the question
In order to leave comments, you need to log in
Why is mysqli_query not executing?
Why does mysqli_query return false ? I tried to insert the request directly into phpMyAdmin - no errors! Everything is entered.
<?php
$link = mysqli_connect("localhost", "*******", "*******");
if ($link == false) {
echo("Ошибка подключения");
} else {
$sql = 'INSERT INTO players SET age = 11';
$result = mysqli_query($link, $sql);
if ($result == false) {
echo("Ошибка при выполнении запроса");
} else {
echo("Данные успешно добавлены");
}
}
?>
Answer the question
In order to leave comments, you need to log in
Probably because you need to pass 4 parameters:
$link = mysqli_connect("127.0.0.1", "my_user", "my_password", "my_db")
Because it is necessary to write not abstract reasoning, "You have an ashypka!" and then guessing with a finger to the sky, and asking the database what specifically it doesn’t like. And she writes everything herself.
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$link = mysqli_connect("localhost", "*******", "*******");
$mysqli->set_charset("utf8mb4");
$sql = 'INSERT INTO players SET age = 11';
$result = mysqli_query($link, $sql);
echo "Данные успешно добавлены";
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question