Adding form data to mySQL, using PHP

Trying to add data from a form to a mySQL database using php

Page 1 of 1

0 Replies - 1592 Views - Last Post: 05 February 2009 - 07:17 PM

#1 chrispringle   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 29-July 08

Adding form data to mySQL, using PHP

Posted 05 February 2009 - 07:17 PM

Hello.

I am running in to a syntax error when i try to add data from a form in to my mySQL database table. I have searched google, but i came up short on an answer.

my Error is:

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'list(ContactID,First,Last,Mail,City,State,Zip,Email,Home,Work,Ce

Any help will be greatly appreciated.
Thank you.

Chris

here is my code.



 <?
$db_host = "mysql2.freehostia.com";
$db_user = "chrtho84_dinner";
$db_pass = "sugarcane";
$db_name = "chrtho84_dinner";

$first=$_POST['Fname'];
$last=$_POST['Lname'];
$mail=$_POST['Mail'];
$city=$_POST['City'];
$state=$_POST['setState'];
$zip=$_POST['Zip'];
$email=$_POST['Email'];
$home=$_POST['Home'];
$work=$_POST['Work'];
$cell=$_POST['Cell'];
$attending=$_POST['Attending'];

mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db($db_name) or die("Could not connect to server: ".mysql_error());

$query = "INSERT INTO guest list(ContactID,First,Last,Mail,City,State,Zip,Email,Home,Work,Cell,Attending) VALUES ('','$first','$last','$mail','$city','$state','$zip','$email','$home','$work', '$cell', '$attending')";
if(!mysql_query($query));
{
	die('Error: ' . mysql_error()); 
}


mysql_close();
?>



Is This A Good Question/Topic? 0
  • +

Page 1 of 1