I see-
here is my debug now:
<?php
include("include/session.php");
$_SESSION['formdata1']=$_POST;
include("connect.php");
//array to hold form errors
$form_error = array();
//validate your form data
if(!isset($_POST['firstname'])){
$form_error[] = "No first name entered";
}
if(!isset($_POST['secondname'])){
$form_error[] = "No second name entered";
}
if(count($form_error) > 0){
//hold the error in session so you can display the error in your form page.
$_SESSION['form_error'] = $form_error;
//redirect to the form
header("Location: http://www.mindseyemidlands.co.uk/notts_quality/info_resource/selfassess_part1a_v1.php");
}
else {
$username = $_SESSION['username'];
$sql = "SELECT * FROM qualityuser WHERE username = '".$username."'";
$result = mysql_query($sql);
// if we have rows, fetch them & prepopulate the form
//check if there and update/insert
if(mysql_num_rows($result) > 0) {
$sqlupdate = 'UPDATE qualityuser SET ' . implode(',', $_SESSION['formdata1']) . ' WHERE username = ' . $_SESSION['username'];
foreach ($_SESSION['formdata1'] as $col => $val) {
if ($col <> 'submit'){
$sqlupdate .=", $col = '$val' ";
}
}
echo $sqlupdate;
mysql_query($sql, $connection) or die(mysql_error());
}
else {
$sqlinsert = "INSERT INTO qualityuser SET qualityuser_id = NULL ";
foreach ($_SESSION['formdata1'] as $col =>$val ){
if($col <> 'submit'){
$sqlinsert .=", $col = '$val' ";
}
}
echo $sqlinsert;
mysql_query($sql, $connection) or die(mysql_error());
and the results:
UPDATE qualityuser SET donald,not selected,Donald,Duck,Disney Co,111,222,333,444,555,1,1,0,0,0,1,1,0,0,0,5 or less,5 or less,5 or less,1,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,submit WHERE username = donald, username = 'donald' , title = 'not selected' , firstname = 'Donald' , secondname = 'Duck' , organisation = 'Disney Co' , telephone = '111' , address1 = '222' , address2 = '333' , town = '444' , postcode = '555' , registeredcharity = '1' , incorporated = '1' , regionalassociation = '0' , regionalcharity = '0' , project = '0' , nature_selfhelp = '1' , nature_frontline = '1' , nature_intermediary = '0' , nature_infrastructure = '0' , nature_partnership = '0' , involved_commitee = '5 or less' , involved_volunteers = '5 or less' , involved_paid = '5 or less' , funded_unrestrictedfunds = '1' , funded_localcouncil = '1' , funded_undercontract = '0' , funded_grants_fees = '0' , funded_socialenterprise = '0' , activity_care = '1' , activity_advice_individual = '1' , activity_advice_organisations = '0' , activity_specialist = '0' , activity_community = '0' , activity_awareness = '0' , activity_sport = '0' , activity_mutual_support = '0' , have_policies_procedures = '1' , have_management_structure = '1' , have_communication = '0' , have_supervision = '0' , have_strategy = '0' , have_aims = '0' , have_review = '0' 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 'not selected,Donald,Duck,Disney Co,111,222,333,444,555,1,1,0,0,