V
V
vot-ono2017-08-07 12:08:14
PHP
vot-ono, 2017-08-07 12:08:14

Why is INSERT INTO not adding data to phpmyadmin?

Hello)
There is a handler that collects data from forms:

<?php
header('Content-Type: text/html; charset=utf-8');
include_once("database.php"); //это подключение к базе через отдельный пхп


if(isset($_POST['add'])) //если нажали на кнопку, но выполнится скрипт ниже
{
    $product = '300';
 $name  = strip_tags(trim($_POST['name']));
  $age = strip_tags(trim($_POST['age']));
  $url   = strip_tags(trim($_POST['url']));
  $mail = strip_tags(trim($_POST['mail']));

  $check = '';
if (!empty($_V["check"]) && is_array($_POST["check"]))
{$check = implode(" ", $_POST["check"]);
}; // сохраняем в переменную данные полученные из чекбоксов

    
    
   $result =  mysql_query(" 
                    INSERT INTO `zakaz` (name, Age, mail, Url, Product, Preferences)
                    VALUES ('$name', '$age', '$mail', '$url', '$product', '$check') 
    ");
}
   if ($result) {
    echo ("Добавление прошло успешно");
} else {
    echo ("Данные не были добавлены");
}
?>

The problem is that the script passes, but the data is not added to the table.
My options:
- I admit that the problem is in the syntax in this line:
INSERT INTO `zakaz` (name, Age, mail, Url, Product, Preferences)
VALUES ('$name', '$age', '$mail', '$ url', '$product', '$check')
- maybe it's the $check variable (combined variable from the checkbox), and for some reason it doesn't want to get into the table
Connoisseurs, please help!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Lysenko, 2017-08-07
@vot-ono

echo mysql_error();
add. Write down what he writes.

V
vot-ono, 2017-08-07
@vot-ono

8726150123884ae78052cac0bcc3d55e.PNG
the plate looks like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question