I was wondering if you could help a PHP and mySQL rookie like me with some simple functions that im having some trouble with?
I have made a contact form which people can contact the firm im doing a website for and be added to their real mail list and email list. But i also want the contact form to store the given data into a table aswell.. to that end i'v written a code based on the simple INSERT code found on w3schools.com and it looks like this:
<?php
$con = mysql_connect("localhost","//username censored//","//password censored//");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("kulturellen", $con);
$sql="INSERT INTO fusion_maillist (visitor, visitormail, visitoradress, visitorcity, visitorphone, visitorcell, concerts, torvet, kunst, other, kulturellen, notes)
VALUES
('$_POST[visitor]','$_POST[visitormail]','$_POST[visitoradress]','$_POST[visitorcity]','$_POST[visitorphone]','$_POST[visitorcell]','$_POST[concerts]','$_POST[torvet]','$_POST[torvet]','$_POST[kunst]','$_POST[other]','$_POST[kulturellen]','$_POST[notes]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 new record added to table";
mysql_close($con)
?>
However when i do that, it gives me following error message:"Error: Column count doesn't match value count at row 1" and my first row is of course the "id" with auto value.. i have included also a screen shot of my mySQL table structure for you to examine and see if i made any errors?

Im using a danish mySQL interface, so if you have any trouble with translations please just ask
I noticed that if i put in a id under colume data like this:
$sql="INSERT INTO fusion_maillist (id, visitor, etc etc
it will write the data into the table, without any error messages, however it will skip my visitor's name and everything will be shown in the wrong coloums.. but im doing it wrong i know.. but just wanted to add, that i have tried to fix it before posting here
So hope that you guys (and gals) can give me a quick and helpfull solution
Thanks in advance..
Kenneth
This post has been edited by Johns3n: 26 March 2009 - 05:12 AM

New Topic/Question
Reply




MultiQuote






|