I am self-learning MySQL and PHP, so please bear with me. I am trying to set up a DB with values being input through a PHP form. I am following along in a book, but cannot find why I am getting the error:
Error Connecting to MySQL server.
I am running a local host, root username, no password, and table called alien_abductions
.
$first_name = $_POST['firstname'];
$last_name = $_POST['lastname'];
$when_happened = $_POST['whenithappened'];
$how_long_gone = $_POST['howlongwereyougone'];
$howmany = $_POST['howmany'];
$description = $_POST['description'];
$whattheydid = $_POST['whattheydid'];
$fangspotted = $_POST['fangspotted'];
$email = $_POST['email'];
$dbc = mysqli_connect('localhost', 'root', '', 'up_amd_running')
or die('Error connecting to MySQL server');
$query = "INSERT INTO alien_abductions (first_name, last_name, " .
"when_happened, how_long_gone, howmany, description, " .
"whattheydid, fangspotted, email " .
"VALUES ('$first_name', '$last_name',
'$when_happened','$how_long_gone', '$howmany', '$description',
'$whattheydid', `'$fangspotted', '$email')";
echo $query;
$result = mysqli_query($dbc, $query)
or die('Error querying database');
mysqli_close($dbc);