my data is not inserting in my phpmyadmin database table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cognition
    New Member
    • May 2013
    • 16

    my data is not inserting in my phpmyadmin database table

    my data is not inserting in my phpmyadmin database table, please kindly help,
    this is my code:
    Code:
    <?php
    
    $first_name = $_POST['firstname'];
    $last_name = $_POST['lastname'];
    $email = $_POST['email'];
    $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'];
    
    $dbc = mysqli_connect('localhost', 'user', 'passw', 'databasename') or die('Error Connection to MySQL Server.');
    
    $query = "INSERT INTO database_table(first_name, last_name, email, when_it_happened, how_long, how_many, alien_description, what_they_did, 'fang_spotted)" . "VALUES('$first_name', '$last_name', '$email', '$when_it_happened', '$how_long', '$how_many', '$alien_description', '$what_they_did', '$fang_spotted')";
    
    $result = mysqli_query($dbc, $query) or die('Error Querying Database.');
        mysqli_close($dbc);
    
    $msg = "First Name: $first_name\n" . "Last Name: $last_name\n" . "Your email address is: $email\n" . "You were abducted: $when_it_happened\n"  .  "and were gone for: $how_long\n" . "How Many are they: $how_many\n" . "Describe them: $alien_description\n" . "What did they do to you: $what_they_did\n" . "Was Fang there? $fang_spotted";
    mail($to, $subject, $msg);
    
    echo 'Thank for submitting the form. <br />';
    echo 'First Name:', $first_name.'<br />';
    echo 'Last Name:', $last_name.'<br />';
    echo 'Your email address is:', $email.'<br />';
    echo 'You were abducted:', $when_it_happened.'<br />';
    echo 'and were gone for:', $how_long.'<br />';
    echo 'How Many are they:', $how_many.'<br />';
    echo 'Describe them:', $alien_description.'<br />';
    echo 'What did they do to you:', $what_they_did.'<br />';
    echo 'Was Fang there?', $fang_spotted.'<br />';
    
    ?>
    this is the feedback i get in my browser: Error Connection to MySQL Server.
Working...