I have a form that should write to MyDQL Database but isn't I have been looking at it for hours and it is driving me crazy.

$sqlquery = "INSERT INTO $table VALUES
'$id','$Name','$DoB_Day','$DoB_Month','$DoB_Year','$Address_1','$Address2','$Town','$Postcode','$Telephone','$Mobile','$Email','$6th_Form','$6th_Form_Year','$6th_Form_Institution','$6th_Form_Course_Title','$College','$College_Year','$College_Name','$College_Course','$E2E','$E2E_Provider','$Apprenticeship','$Apprenticeship_Level','$App_Employer_Name','$App_Work_Area','$Employment','$Employment_Basis','$Emp_Employer_Name','$Emp_Job_Title','$Emp_Training','$University','$University_Name','$Uni_Course_Title','$Gap_Year','$Unemployed','$Other')";

I have used this method before and it worked fine but it just isn't playing nicely today.

I have also tried the following;

$sqlquery = "INSERT INTO `connx_iPOD_Comp` ( `id` , `Name` , `DoB_Day` , `DoB_Month` , `DoB_Year` , `Address_1` , `Address2` , `Town` , `Postcode` , `Telephone` , `Mobile` , `Email` , `6th_Form` , `6th_Form_Year` , `6th_Form_Institution` , `6th_Form_Course_Title` , `College` , `College_Year` , `College_Name` , `College_Course` , `E2E` , `E2E_Provider` , `Apprenticeship` , `Apprenticeship_Level` , `App_Employer_Name` , `App_Work_Area` , `Employment` , `Employment_Basis` , `Emp_Employer_Name` , `Emp_Job_Title` , `Emp_Training` , `University` , `University_Name` , `Uni_Course_Title` , `Gap_Year` , `Unemployed` , `Other` ) '
        . 'VALUES('$Name','$DoB_Day','$DoB_Month','$DoB_Year','$Address_1','$Address2','$Town','$Postcode','$Telephone','$Mobile','$Email','$6th_Form','$6th_Form_Year','$6th_Form_Institution','$6th_Form_Course_Title','$College','$College_Year','$College_Name','$College_Course','$E2E','$E2E_Provider','$Apprenticeship','$Apprenticeship_Level','$App_Employer_Name','$App_Work_Area','$Employment','$Employment_Basis','$Emp_Employer_Name','$Emp_Job_Title','$Emp_Training','$University','$University_Name','$Uni_Course_Title','$Gap_Year','$Unemployed','$Other')";

From what I see... In the first one, you forgot the opening parenthesis. In the second one, you have mismatched values.

Try this:

$sqlquery = "INSERT INTO $table VALUES
('$id','$Name','$DoB_Day','$DoB_Month','$DoB_Year','$Address_1','$Address2','$Town','$Postcode','$Telephone','$Mobile','$Email','$6th_Form','$6th_Form_Year','$6th_Form_Institution','$6th_Form_Course_Title','$College','$College_Year','$College_Name','$College_Course','$E2E','$E2E_Provider','$Apprenticeship','$Apprenticeship_Level','$App_Employer_Name','$App_Work_Area','$Employment','$Employment_Basis','$Emp_Employer_Name','$Emp_Job_Title','$Emp_Training','$University','$University_Name','$Uni_Course_Title','$Gap_Year','$Unemployed','$Other')";

And by the way... if I'm not terribly mistaken... if the ID column is set as auto_increment, then you should use the code below. If it's not... then ignore the code below.

$sqlquery = "INSERT INTO $table VALUES
('','$Name','$DoB_Day','$DoB_Month','$DoB_Year','$Address_1','$Address2','$Town','$Postcode','$Telephone','$Mobile','$Email','$6th_Form','$6th_Form_Year','$6th_Form_Institution','$6th_Form_Course_Title','$College','$College_Year','$College_Name','$College_Course','$E2E','$E2E_Provider','$Apprenticeship','$Apprenticeship_Level','$App_Employer_Name','$App_Work_Area','$Employment','$Employment_Basis','$Emp_Employer_Name','$Emp_Job_Title','$Emp_Training','$University','$University_Name','$Uni_Course_Title','$Gap_Year','$Unemployed','$Other')";

Cheers Patrick it was the Parenthesis I think it was a case of looking at the same code for too long and not being able to see the wood for the trees.

Cheers
Mark

Haha. That can do it alright! I'm glad I could help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.