You have an error in your SQL syntax near ''','Mr','','','','','','','','','','','','','','','','','','','','','','','')' at line 1
can this be fixed without reconstructing my Insert statement.
Also the most frustrating thing is that once I have changed my insert statement - which already worked - I will then still have to try and solve my header problem - one thing at a time hey!!
Heres my original code which worked perfectly fine but the header Problem was not allowing a blank form to load.
Code: Select all
<?php
/*Connecting, selecting database*/
$link = mysql_connect("xxx", "xxx", "xxxx")
or die("Could not connect : " . mysql_error());
mysql_select_db("contact_management_system",$link) or die("Could not select database");
$var1 = $_POST["dateoflastcontact_Year"];
$var2 = $_POST["dateoflastcontact_Day"];
$var3 = $_POST["dateoflastcontact_Month"];
$dateoflastcontact = $var1."-".$var3."-".$var2;
$var1 = $_POST["datecontactagain_Year"];
$var2 = $_POST["datecontactagain_Day"];
$var3 = $_POST["datecontactagain_Month"];
$datecontactagain = $var1."-".$var3."-".$var2;
$sql = "INSERT INTO people
(
person_id, salutation, firstname, surname,
organisation, role, address1, address2,
city, postcode, telephone, mobile, fax,
dateoflastcontact, datecontactagain, notes, email,
org_id, consultation_panel_member, primary_contact, primarycontactemail, advertising_grad_jobs,offer_mscproject,offer_ugproject,
professional_devactivities,bcs_membership,bcs_pds,
teaching_courses,academic_consultancy,employer_feedback
)
VALUES
(
'$person_id','$salutation','$firstname','$surname',
'$organisation', '$role', '$address1', '$address2',
'$city', '$postcode', '$telephone', '$mobile', '$fax','$dateoflastcontact',
'$datecontactagain','$notes','$email','$org_id',
'$consultation_panel_member','$primary_contact',
'$primarycontactemail','$advertising_grad_jobs',
'$offer_mscproject','$offer_ugproject',
'$professional_devactivities','$bcs_membership','$bcs_pds',
'$teaching_courses','$academic_consultancy','$employer_feedback'
)";
$result = mysql_query($sql, $link) or die ( mysql_error($link));;
header("location: http://www.soi.city.ac.uk/organisation/ ... eople.html");
?>
As I said before the code inserted a record perfectly it was just that I was getting a blank sceen and not a blank new form.
The eerror Messages:
1 - PHP NOTICE - Undefined Variable: notes in processpeople.php at line 43
2- PHP WARNING - Cannot modify header information - headers already sent on line 52
Ok Now here is the code that It was suggested I try - which is a variation of what I had originally
Code: Select all
<?php
/*Connecting, selecting database*/
$link = mysql_connect("xxx", "xxx", "xxxx")
or die("Could not connect : " . mysql_error());
mysql_select_db("contact_management_system",$link) or die("Could not select database");
$var1 = $_POST["dateoflastcontact_Year"];
$var2 = $_POST["dateoflastcontact_Day"];
$var3 = $_POST["dateoflastcontact_Month"];
$dateoflastcontact = $var1."-".$var3."-".$var2;
$var1 = $_POST["datecontactagain_Year"];
$var2 = $_POST["datecontactagain_Day"];
$var3 = $_POST["datecontactagain_Month"];
$datecontactagain = $var1."-".$var3."-".$var2;
$sql = "INSERT INTO people (";
$sql .= "'".$_POST['person_id']."',";
$sql .= "'".$_POST['salutation']."',";
$sql .= "'".$_POST['surname']."',";
$sql .= "'".$_POST['organisation']."',";
$sql .= "'".$_POST['role']."',";
$sql .= "'".$_POST['role']."',";
$sql .= "'".$_POST['address1']."',";
$sql .= "'".$_POST['address2']."',";
$sql .= "'".$_POST['city']."',";
$sql .= "'".$_POST['postcode']."',";
$sql .= "'".$_POST['telephone']."',";
$sql .= "'".$_POST['email']."',";
$sql .= "'".$_POST['org_id']."',";
$sql .= "'".$_POST['consultation_panel_member']."',";
$sql .= "'".$_POST['primary_contact']."',";
$sql .= "'".$_POST['primarycontactemail']."',";
$sql .= "'".$_POST['advertising_grad_jobs']."',";
$sql .= "'".$_POST['offer_mscproject']."',";
$sql .= "'".$_POST['offer_ugproject']."',";
$sql .= "'".$_POST['professional_devactivities']."',";
$sql .= "'".$_POST['bcs_membership']."',";
$sql .= "'".$_POST['bcs_pds']."',";
$sql .= "'".$_POST['teaching_courses']."',";
$sql .= "'".$_POST['academic_consultancy']."',";
$sql .= "'".$_POST['employer_feedback']."'";
$sql .= ")";
$result = mysql_query($sql, $link) or die ( mysql_error($link));;
header("location: http://www.soi.city.ac.uk/organisation/ ... eople.html");
?>
and heres the error message for this code:
You have an error in your SQL syntax near ''','Mr','','','','','','','','','','','','','','','','','','','','','','','')' at line 1
Ok thanks for your patience -any ideas