Не записываются данные в БД

Nempak

Новичок
В index.html вставил форму:

HTML:
  <form method="post" action="report.php">
    <label for="firstname">First name:</label>
    <input type="text" id="firstname" name="firstname" /><br />
    <label for="lastname">Last name:</label>
    <input type="text" id="lastname" name="lastname" /><br />
    <label for="email">What is your email address?</label>
    <input type="text" id="email" name="email" /><br />
    <label for="whenithappened">When did it happen?</label>
    <input type="text" id="whenithappened" name="whenithappened" /><br />
    <label for="howlong">How long were you gone?</label>
    <input type="text" id="howlong" name="howlong" /><br />
    <label for="howmany">How many did you see?</label>
    <input type="text" id="howmany" name="howmany" /><br />
    <label for="aliendescription">Describe them:</label>
    <input type="text" id="aliendescription" name="aliendescription" size="32" /><br />
    <label for="whattheydid">What did they do to you?</label>
    <input type="text" id="whattheydid" name="whattheydid" size="32" /><br />
    <label for="fangspotted">Have you seen my dog Fang?</label>
    Yes <input id="fangspotted" name="fangspotted" type="radio" value="yes" />
    No <input id="fangspotted" name="fangspotted" type="radio" value="no" /><br />
    <img src="fang.jpg" width="100" height="175"
      alt="My abducted dog Fang." /><br />
    <label for="other">Anything else you want to add?</label>
    <textarea id="other" name="other"></textarea><br />
    <input class='btn btn-success' type="submit" value="Report Abduction" name="submit" />
  </form>
В report.php получаю введенные данные и пытаюсь их занести в базу, но получаю ошибку 2

PHP:
<?php
  $fname = $_POST['firstname'];
  $sname = $_POST['lastname'];
  $when_it_happened = $_POST['whenithappened'];
  $how_long = $_POST['howlong'];
  $how_many = $_POST['howmany'];
  $alien_description = $_POST['aliendescription'];
  $what_they_did = $_POST['whattheydid'];
  $fang_spotted = $_POST['fangspotted'];
  $email = $_POST['email'];
  $other = $_POST['other'];

  $dbc = mysqli_connect('localhost', 'root', '', 'aliendatabase') or die('Ошибка соединения с базой');
  $query = "INSERT INTO aliens_abduction (firts_name, last_name, when_it_happened, how_long, how_many,
alien_description, what_they_did, fang_spotted, email, other)
VALUES('$fname', '$sname', '$when_it_happened','$how_long', '$how_many', '$alien_description', '$what_they_did', '$fang_spotted', '$email', '$other')";
  $result = mysqli_query($dbc, $query) or die("Ошибка 2");
  mysqli_close();
   
  echo 'Thanks for submitting the form.<br />';
  echo $fname . ' ' . $sname . '<br>';
  echo 'You were abducted ' . $when_it_happened;
  echo ' and were gone for ' . $how_long . '<br />';
  echo 'Number of aliens: ' . $how_many . '<br />';
  echo 'Describe them: ' . $alien_description . '<br />';
  echo 'The aliens did this: ' . $what_they_did . '<br />';
  echo 'Was Fang there? ' . $fang_spotted . '<br />';
  echo 'Other comments: ' . $other . '<br />';
  echo 'Your email address is ' . $email;
?>
В чем может быть проблема?
В phpmyadmin база данных создана и таблица таблица тоже, перепроверил.
 

xopagpuk

Профан - программист.
Итак, идем по циклу: вы подключились к базе данных. Затем переменной $query присвоили значение запроса. А где у вас сам запрос?
Удалите из строки запроса "or die("Ошибка 2")" и добавьте после:
$result = mysqli_query($dbc,$query);
А так ознакомьтесь:
http://php.net/manual/ru/mysqli.query.php
 
Сверху