Answer the question
In order to leave comments, you need to log in
Why doesn't PHP push content into MySQL database?
I tried to do "Entering content into the database using the POST method", but something did not work out for me. All code compiles without errors, but in MySQL database -> PHPmyAdmin shows nothing in the database. What could it be? Maybe my code is wrong? Or am I not putting the data into the database correctly?
index.php:
<form method="post" action="processing.php">
Названия<input name="title"><br>
Описания<input name="first_description"><br>
Второе описания<input name="second_description"><br>
Автор<input name="author"><br>
<input type="submit">
</form>
$title = $_POST['title'];
$first_description = $_POST['first_description'];
$second_description = $_POST['second_description'];
$author = $_POST['author'];
$link = mysqli_connect('localhost', 'simple_user', 'qwerty', 'post_method');
if(!$link) {
echo "Ошибка подключения базы данных: " . mysqli_error();
}else {
echo "Подключения прошла успешно!";
}
$sql = "
INSERT INTO content (title,fisrt_description,second_description,author)
VALUES($title,$first_description,$second_description,$author)
";
$query = mysqli_query($link,$sql);
Answer the question
In order to leave comments, you need to log in
PHP variables in the string are changed to unquoted values ! Need to put
$sql = "INSERT INTO content (title,fisrt_description,second_description,author) VALUES('$title','$first_description','$second_description','$author')";
. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question