I found a really great book and following a tutorial and receiving a warning:
here is my code:Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\xampp\htdocs\aliens_abduction\report.php on line 29
Code: Select all
<?php
$host = "localhost";
$user = "root";
$pass = "1122334";
$database = "aliendatabase";
$db = mysqli_connect($host, $user, $pass, $database) or die("you did not connect bozo");
//Abduction_report engine.
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$when_it_happened = $_POST['when_it_happened'];
$how_long = $_POST['how_long'];
$how_many = $_POST['how_many'];
$alien_description = $_POST['alien_description'];
$what_they_did = $_POST['what_they_did'];
$fang_spotted = $_POST['fang_spotted'];
$other = $_POST['other'];
$email = $_POST['email'];
$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 ('$first_name', '$last_name', '$when_it_happened', '$how_long', '$how_many', " .
"'$alien_description', '$what_they_did', '$fang_spotted', '$other', '$email')";
$result = mysqli_query($db, $query)
or die(mysqli_error());----------------------------------------this is line 29
mysqli_close($db);
echo 'Thanks for submitting the form.<br />';
echo 'You were abducted ' . $when_it_happened;
echo ' and were gone for ' . $how_long . '<br />';
echo 'Number of aliens: ' . $how_many . '<br />';
echo 'Describe them: ' . $alien_description . '<br />';
echo 'The aliens did this: ' . $what_they_did . '<br />';
echo 'Was Fang there? ' . $fang_spotted . '<br />';
echo 'Other comments: ' . $other . '<br />';
echo 'Your email address is ' . $email;
?>I also done a var_dump($query) right after query and all looks normal, all the values are there. connection to DB works fine too no error there. I know it's something stupid, i just can't see it lol. I know, I know.... I will get better glasses soon.