Simple SQL/PHP - INSERT statement not working?

John Wilson

New member
Hi folks,

im just teaching myself php and mysql using the headfirst book but im a little bit stuck being a noob to this code. Im using phpmyadmin for the database and tables and ive succesfully connected to the database BUT the query is coming back error querying database..this is the php code ive got...

<?php
$dbc =' ', 'username', 'password', 'database name')
or die('Error connecting to the 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 ('Sally', 'Jones', '3 days ago'. '1 day', 'four', " .
"'green with six tentacles', 'We just talked and played with a dog', " .
"'yes', 'I may have seen your dog. Contact me.', " .
"'[email protected]')" ;

$result = mysqli_query($dbc, $query)
or die('Error querying database.');
?>

Can anyone help me? :)

Cheers.

John
i use the mysqli_connect before $dbc i deleted a bit too much info when i was posting the question.

the error that comes back on the screen when submitting the form is simply "error querying database" so some part of the query is wrong. Just finding out which part of it is the tricky bit.
 
Back
Top