Jump to content
chpt 2 - "error querying database"
65 replies to this topic
Posted 26 December 2011 - 08:41 AM
I believe that has to be:
Posted 26 December 2011 - 12:09 PM
It's still returning a blank page when I swap that snippet in. Here is my full code now:
<title>Aliens Abducted Me - Report an Abduction</title>
<h2>Aliens Abducted Me - Report an Abduction</h2>
$first_name = $_POST['firstname'];
$last_name = $_POST['lastname'];
$when_it_happened = $_POST['whenithappened'];
$how_long = $_POST['howlong'];
$alien_description = $_POST['aliendescription'];
$fang_spotted = $_POST['fangspotted'];
$email = $_POST['email'];
$how_many = $_POST['howmany'];
$what_they_did = $_POST['whattheydid'];
$other = $_POST['other'];
$dbc = mysqli_connect('localhost:8889', 'root', 'root', 'aliendatabase')
or die('Error connecting to MySQL server.');
$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($dbc, $query)
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 commentsd: ' . $other . '<br />';
echo 'Your email address is '. $email;
Posted 26 December 2011 - 12:19 PM
You're missing a single quote in your query before what_they_did.
Posted 03 August 2013 - 02:03 PM
I am having the same problem, I am using a mac.. I am having a hard time with it, I have all the latest stuff but ti still cant access the database
Posted 11 July 2014 - 04:43 AM
I literally had the same problem.
I spent HOURS trying to figure it out, thanks for sharing your tip!
How do you ensure that's the user can input ' s in the input field without it breaking the database query is my next question?
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users