title: Connected successfully Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table
body: <p>i'm just starting to study php and I got this error:</p>
  
  <blockquote>
    <p>Connected successfully<br>
    Fatal error: Uncaught exception 'PDOException' with message    'SQLSTATE[42S02]: Base table or view not found: 1146 Table    'aliendatabase.alien_abduction' doesn't exist' in    C:\xampp\htdocs\study\report.php:39 Stack trace: #0 C:\xampp\htdocs\study\report.php(39): PDO->exec('INSERT INTO ali...') #1 {main}   thrown in C:\xampp\htdocs\study\report.php on line 39</p>
  </blockquote>
  
  <p>Here my html form:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Aliens Abducted Me - Report an Abduction&lt;/title&gt;
  &lt;link rel="stylesheet" type="text/css" href="style.css" /&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h2&gt;Aliens Abducted Me - Report an Abduction&lt;/h2&gt;
  
  &lt;p&gt;Share your story of alien abduction:&lt;/p&gt;
  &lt;form method="post" action="report.php"&gt;
  &lt;label for="firstname"&gt;First name:&lt;/label&gt;
  &lt;input type="text" id="firstname" name="firstname" /&gt;&lt;br /&gt;
  &lt;label for="lastname"&gt;Last name:&lt;/label&gt;
  &lt;input type="text" id="lastname" name="lastname" /&gt;&lt;br /&gt;
  &lt;label for="email"&gt;What is your email address?&lt;/label&gt;
  &lt;input type="text" id="email" name="email" /&gt;&lt;br /&gt;
  &lt;label for="whenithappened"&gt;When did it happen?&lt;/label&gt;
       &lt;input type="text" id="whenithappened" name="whenithappened" /&gt;&lt;br /&gt;
       &lt;label for="howlong"&gt;How long were you gone?&lt;/label&gt;
       &lt;input type="text" id="howlong" name="howlong" /&gt;&lt;br /&gt;
       &lt;label for="howmany"&gt;How many did you see?&lt;/label&gt;
       &lt;input type="text" id="howmany" name="howmany" /&gt;&lt;br /&gt;
       &lt;label for="aliendescription"&gt;Describe them:&lt;/label&gt;
       &lt;input type="text" id="aliendescription" name="aliendescription" size="32" /&gt;&lt;br /&gt;
       &lt;label for="whattheydid"&gt;What did they do to you?&lt;/label&gt;
       &lt;input type="text" id="whattheydid" name="whattheydid" size="32" /&gt;&lt;br /&gt;
       &lt;label for="fangspotted"&gt;Have you seen my dog Fang?&lt;/label&gt;
       Yes &lt;input id="fangspotted" name="fangspotted" type="radio" value="yes" /&gt;
       No &lt;input id="fangspotted" name="fangspotted" type="radio" value="no" /&gt;&lt;br /&gt;
       &lt;img src="fang.jpg" width="100" height="175"
    alt="My abducted dog Fang." /&gt;&lt;br /&gt;
       &lt;label for="other"&gt;Anything else you want to add?&lt;/label&gt;
       &lt;textarea id="other" name="other"&gt;&lt;/textarea&gt;&lt;br /&gt;
       &lt;input type="submit" value="Report Abduction" name="submit" /&gt;
     &lt;/form&gt;
   &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>
  
  <p>Here my php page:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Aliens Abducted Me - Report an Abduction&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h2&gt;Aliens Abducted Me - Report an Abduction&lt;/h2
  
  &lt;?php
   $first_name = $_POST['firstname'];
   $last_name = $_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'];
  
   $servername = "localhost";
   $username = "davide";
   $password = "";
  
   {
   $conn = new PDO("mysql:host=$servername;dbname=aliendatabase", $username,        $password);
  
  $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  echo "Connected successfully";
  }
  $sql = "INSERT INTO alien_abduction (first_name, last_name, when_it_happened, how_long, " .
      "how_many, alien_description, what_they_did, fang_spotted, other, email)" .
      "VALUES ('$first_name', '$last_name', '$when_it_happened', '$how_long', '$how_many', " .
      "'$alien_description', '$what_they_did', '$fang_spotted', '$other', '$email')";
  
  $conn-&gt;exec($sql);
  echo "New record created successfully";
  
  
  {
  echo "Connection failed: " . $e-&gt;getMessage();
  }
  
  $conn = null;
  
  echo 'Thanks for submitting the form.&lt;br /&gt;';
  echo 'You were abducted ' . $when_it_happened;
  echo ' and were gone for ' . $how_long . '&lt;br /&gt;';
  echo 'Number of aliens: ' . $how_many . '&lt;br /&gt;';
  echo 'Describe them: ' . $alien_description . '&lt;br /&gt;';
  echo 'The aliens did this: ' . $what_they_did . '&lt;br /&gt;';
  echo 'Was Fang there? ' . $fang_spotted . '&lt;br /&gt;';
  echo 'Other comments: ' . $other . '&lt;br /&gt;';
  echo 'Your email address is ' . $email;
  ?&gt;
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>What's wrong? Please can someone explain it?
  I'm running apache and mysql server by xampp in localhost</p>