Cant get it to add data

Hi
PLEASE help
I cant get this data to add to the Mysql database Ive added the correct fields in MYSQl just cant seem to get it to work
the form is http://www.interactive-corporation.com/contract/php/files/contract.htm
this send on submit to post.ph
File below I have removed the username and password

<?php $username="DATABASE USERNAME"; $password="DATABASE PASSWORD"; $database="DATABASE NAME"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO membership VALUES ('','$Date ","$FPname" , "$FPsurname","$D1" , "$SPname" , "$SPsurname" , "$Address" , "$City" , "$Country" , ".$zipcode" , "$nationality" , "$homephone" , "$mobilephone" , "$Fax" , "$email1" , "$Semail2" , ".$membershiplemgth." , ".$membershiptype" , "$membershipprice" , "$adminfee" , "$totalprice" , "$deposit" , "$balance" , "$installments" , "$installmentamount" , "$firstpayment." , "$mtfamount'); mysql_query($query); mysql_close(); ?>

HI,

Here is the problem

[php]
$query = “INSERT INTO membership VALUES
(’’,’$Date “,”$FPname” , “$FPsurname”,"$D1" , “$SPname” , “$SPsurname” , “$Address” , “$City” , “$Country” , “.$zipcode” , “$nationality” , “$homephone” , “$mobilephone” , “$Fax” , “$email1” , “$Semail2” , “.$membershiplemgth.” , “.$membershiptype” , “$membershipprice” , “$adminfee” , “$totalprice” , “$deposit” , “$balance” , “$installments” , “$installmentamount” , “$firstpayment.” , "$mtfamount’);
[/php]

Solution:
Your Insert syntax was wrong.

Here is correct syntax.
[php]
INSERT INTO tutorials_tbl
(tutorial_title, tutorial_author, submission_date)
VALUES
(“Learn PHP”, “John Poul”, NOW());
[/php]

I thought this is where you get help.
Ive changed it to please help everyone has to start somewhere

<?php $username="DATABASE USERNAME"; $password="DATABASE PASSWORD"; $database="DATABASE NAME"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO membership VALUES ("$Date", "$FPname", "$FPsurname", "$D1", "$SPname", "$SPsurname", "$Address", "$City", "$Country", "$zipcode", "$nationality", "$homephone", "$mobilephone", "$Fax", "$email1", "$Semail2", "$membershiplemgth", "$membershiptype", "$membershipprice", "$adminfee", "$totalprice", "$deposit", "$balance", "$installments", "$installmentamount", "$firstpayment", "$mtfamount'()); mysql_query($query); mysql_close(); ?>

Hey Buddy,

I’m new here so let’s see if i can help out.

Start small with the form/query.

Try this
[php]

<?php $username="DATABASE USERNAME"; $password="DATABASE PASSWORD"; $database="DATABASE NAME"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); /** * Specify the DB fields that you are adding POST data from the from below * Just try a single field first i.e. specify the date field, and then specify the * POST variable input box with a name of date from your HTML form */ $query = "INSERT INTO membership VALUES (date) VALUES ('" . $_POST['date'] . "')"; /** * Add error checking to the query below */ mysql_query($query) or die("ERROR: " . mysql_error());; mysql_close(); /////////////////////////////////////////////////////////////////////////////// /** * The keep adding DB fields and POST variables until the query is complete. */ $query = "INSERT INTO membership VALUES (Date, FPname) VALUES ('" . $_POST['Date'] . "', '" . $_POST['FPname'] . "' )"; $query = "INSERT INTO membership (Date, FPname, FPsurname) VALUES ('" . $_POST['Date'] . "', '" . $_POST['FPname'] . "', '" . $_POST['FPsurname'] . "')"; [/php] Hope this helps Send back any errors if you still have trouble $query = "INSERT INTO membership VALUES (date, FPname, ) VALUES ('" . $_POST['date'] . "', '" . $_POST['FPname'] . "' )";

always put a [php]or Die(‘my line of code 1020’); [/php] at the end of a mysql query so you know its working or not

Sponsor our Newsletter | Privacy Policy | Terms of Service