By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,868 Members | 1,974 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,868 IT Pros & Developers. It's quick & easy.

my data is not inserting in my phpmyadmin database table

cognition
P: 16
my data is not inserting in my phpmyadmin database table, please kindly help,
this is my code:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $first_name = $_POST['firstname'];
  4. $last_name = $_POST['lastname'];
  5. $email = $_POST['email'];
  6. $when_it_happened = $_POST['whenithappened'];
  7. $how_long = $_POST['howlong'];
  8. $how_many = $_POST['howmany'];
  9. $alien_description = $_POST['aliendescription'];
  10. $what_they_did = $_POST['whattheydid'];
  11. $fang_spotted = $_POST['fangspotted'];
  12.  
  13. $dbc = mysqli_connect('localhost', 'user', 'passw', 'databasename') or die('Error Connection to MySQL Server.');
  14.  
  15. $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')";
  16.  
  17. $result = mysqli_query($dbc, $query) or die('Error Querying Database.');
  18.     mysqli_close($dbc);
  19.  
  20. $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";
  21. mail($to, $subject, $msg);
  22.  
  23. echo 'Thank for submitting the form. <br />';
  24. echo 'First Name:', $first_name.'<br />';
  25. echo 'Last Name:', $last_name.'<br />';
  26. echo 'Your email address is:', $email.'<br />';
  27. echo 'You were abducted:', $when_it_happened.'<br />';
  28. echo 'and were gone for:', $how_long.'<br />';
  29. echo 'How Many are they:', $how_many.'<br />';
  30. echo 'Describe them:', $alien_description.'<br />';
  31. echo 'What did they do to you:', $what_they_did.'<br />';
  32. echo 'Was Fang there?', $fang_spotted.'<br />';
  33.  
  34. ?>
this is the feedback i get in my browser: Error Connection to MySQL Server.
Jun 10 '13 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.