I'm attempting to connect my first php script to the mysql database. I'm using XAMPP as my server. I keep getting the message "error querying database".
Bellow is my code. I really would appreciate the help.
//Below is how you connect to a database and insert data
//First create a variable with the connection commands so the query function you will use in a moment won't be so long
$dbc = mysqli_connect('localhost', 'root', '', 'aliendatabase') or die ('Error connecting to MySQL server.');
//Next create a variable to hold your query commands for the same reason
$query = "INSERT INTO aliens_abduction (first_name, last_name " .
"when_it_happened, how_long, how_many, alien_description, " .
"what_they_did, fang_spotted, other, email) " .
"VALUES ('Sally', 'Jones', '3 days ago', '1 day', 'four', " .
"'slimmy', 'asked questions', " .
"'yes', 'I may have seen your dog. Contact me.', " .
"'sally@gregs-list.net')";
//Now the variable that holds the query function
$result = mysqli_query($dbc, $query)
or die ('Error querying database.');