Im getting an error message and I have no idea why because there is nothing on the line in question (the last line of this code)
Note im building a multipage form using sessions to hold the values in an array which is highlighted in bold

<?php 
//open the db connection 
include("connect.php"); 
//carry on the session array thats holding the data values 
session_start(); 
foreach($_POST as $key => $val) 
{ 
$_SESSION[$key] = $val; 
} 

if (isset($_POST['Submit'])) { 

$contact = $_POST['contact']; 
$nameorg = $_POST['nameorg']; 
$telephone = $_POST['telephone']; 
$besttimecontact = $_POST['besttimecontact']; 
$address1 = $_POST['address1']; 
$address2 = $_POST['address2']; 
$town = $_POST['town']; 
$county = $_POST['county']; 
$postcode = $_POST['postcode']; 
$fax = $_POST['fax']; 
$email = $_POST['email']; 
$website = $_POST['website']; 
$govoffreg = $_POST['govoffreg']; 
$premises = $_POST['premises']; 
$commitee = $_POST['commitee']; 
$fundingsources = $_POST['fundingsources']; 
$bmeorg = $_POST['bmeorg']; 
$ethnicityusers = $_POST['ethnicityusers']; 
$orgtype = $_POST['orgtype']; 
$activities = $_POST['activities']; 
$beneficiaries = $_POST['beneficiaries']; 
$contactrole = $_POST['contactrole']; 
$legalstatus = $_POST['legalstatus']; 
$levelorg = $_POST['levelorg']; 
$areaop = $_POST['areaop']; 
$income = $_POST['income']; 
$ft30plus = $_POST['ft30plus']; 
$pt16hrs = $_POST['pt16hrs']; 
$pt1630hrs = $_POST['pt1630hrs']; 
$sessional = $_POST['sessional']; 
$trainers = $_POST['trainers']; 
$unclassified = $_POST['unclassified']; 
$volunteer = $_POST['volunteer']; 
$common_whatexpect = $_POST['common_whatexpect']; 
$reliable = $_POST['reliable']; 
$cheap = $_POST['cheap']; 
$personalservice = $_POST['personalservice']; 
$slow = $_POST['slow']; 
$qualifiedstaff_people = $_POST['qualifiedstaff_people']; 
$widechoice = $_POST['widechoice']; 
$consistent = $_POST['consistent']; 
$approachable = $_POST['approachable']; 
$fitforpurpose = $_POST['fitforpurpose']; 
$welleducated = $_POST['welleducated']; 
$friendly = $_POST['friendly']; 
$prompt = $_POST['prompt']; 
$attentive = $_POST['attentive']; 
$speedy = $_POST['speedy']; 
$meetsneeds = $_POST['meetsneeds']; 
$takeson = $_POST['takeson']; 
$providesxtras = $_POST['providesxtras']; 
$handson = $_POST['handson']; 
$responsive = $_POST['responsive']; 
$ltdselection = $_POST['ltdselection']; 
$competent = $_POST['competent']; 
$affordable = $_POST['affordable']; 
$accessible = $_POST['accessible']; 
$knowledgeable = $_POST['knowledgeable']; 
$checkssatisfaction = $_POST['checkssatisfaction']; 
$getsdetails = $_POST['getsdetails']; 
$understands = $_POST['understands']; 
$important1 = $_POST['important1']; 
$important2 = $_POST['important2']; 
$important3 = $_POST['important3']; 
$important4 = $_POST['important4']; 
$important5 = $_POST['important5']; 
$nameofsystems = $_POST['nameofsystems']; 
$not_adopting_sys_1 = $_POST['not_adopting_sys_1']; 
$not_adopting_sys_2 = $_POST['not_adopting_sys_2']; 
$not_adopting_sys_3 = $_POST['not_adopting_sys_3']; 
$not_adopting_sys_4 = $_POST['not_adopting_sys_4']; 
$not_adopting_sys_5 = $_POST['not_adopting_sys_5']; 
$not_adopting_sys_6 = $_POST['not_adopting_sys_6']; 
$not_adopting_sys_7 = $_POST['not_adopting_sys_7']; 
$not_adopting_sys_8 = $_POST['not_adopting_sys_8']; 

$sql = "INSERT INTO nottsvcs (contact, nameorg, telephone, besttimecontact 
,address1 
,address2 
,town 
,county 
,postcode 
,fax 
,email 
,website 
,govoffreg 
,premises 
,commitee 
,fundingsources 
,bmeorg 
,ethnictyusers 
,orgtype 
,activities 
,beneficiaries 
,contactrole 
,legalstatus 
,levelorg 
,areaop 
,incomeft30plus 
,pt16hrs 
,pt1630hrs 
,sessional 
,trainers 
,unclassified 
,volunteer 
,common_whatexpec 
,reliable 
,cheap 
,personalservice 
,slow 
,qualifiedstaff_people 
,widechoice 
,consistent 
,approachable 
,fitforpurpose 
,welleducated 
,friendly 
,prompt 
,attentive 
,speedy 
,meetsneeds 
,takeson 
,providesxtras 
,handson 
,responsive 
,ltdselection 
,competent 
,affordable 
,accessible 
,knowledgeable 
,checkssatisfaction 
,getsdetails 
,understands 
,important1 
,important2 
,important3 
,important4 
,important5 
,nameofsystems 
,not_adopting_sys_1 
,not_adopting_sys_2 
,not_adopting_sys_3 
,not_adopting_sys_4 
,not_adopting_sys_5 
,not_adopting_sys_6 
,not_adopting_sys_7 
,not_adopting_sys_8) 


VALUES ($_SESSION'['$contact']' 
,$_SESSION'['$nameorg']' 
,$_SESSION'['$telephone']' 
,$_SESSION'['$besttimecontact']' 
,$_SESSION'['$address1']' 
,$_SESSION'['$address2']' 
,$_SESSION'['$town']' 
,$_SESSION'['$county']' 
,$_SESSION'['$postcode']' 
,$_SESSION'['$fax']' 
,$_SESSION'['$email']' 
,$_SESSION'['$website']' 
,$_SESSION'['$govoffreg']' 
,$_SESSION'['$premises']' 
,$_SESSION'['$commitee']' 
,$_SESSION'['$fundingsources']' 
,$_SESSION'['$bmeorg']' 
,$_SESSION'['$ethnictyusers']' 
,$_SESSION'['$orgtype']' 
,$_SESSION'['$activities']' 
,$_SESSION'['$beneficiaries']' 
,$_SESSION'['$contactrole']' 
,$_SESSION'['$legalstatus']' 
,$_SESSION'['$levelorg']' 
,$_SESSION'['$areaop']' 
,$_SESSION'['$income']' 
,$_SESSION'['$ft30plus']' 
,$_SESSION'['$pt16hrs']' 
,$_SESSION'['$pt1630hrs']' 
,$_SESSION'['$sessional']' 
,$_SESSION'['$trainers']' 
,$_SESSION'['$unclassified']' 
,$_SESSION'['$volunteer']' 
,$_SESSION'['$common_whatexpect']' 
,$_SESSION'['$reliable']' 
,$_SESSION'['$cheap']' 
,$_SESSION'['$personalservice']' 
,$_SESSION'['$slow']' 
,$_SESSION'['$qualifiedstaff_people']' 
,$_SESSION'['$widechoice']' 
,$_SESSION'['$consistent']' 
,$_SESSION'['$approachable']' 
,$_SESSION'['$fitforpurpose']' 
,$_SESSION'['$welleducated']' 
,$_SESSION'['$friendly']' 
,$_SESSION'['$prompt']' 
,$_SESSION'['$attentive']' 
,$_SESSION'['$speedy']' 
,$_SESSION'['$meetsneeds']' 
,$_SESSION'['$takeson']' 
,$_SESSION'['$providesxtras']' 
,$_SESSION'['$handson']' 
,$_SESSION'['$responsive']' 
,$_SESSION'['$ltdselection']' 
,$_SESSION'['$competent']' 
,$_SESSION'['$affordable']' 
,$_SESSION'['$accessible']' 
,$_SESSION'['$knowledgeable']' 
,$_SESSION'['$checkssatisfaction']' 
,$_SESSION'['$getsdetails']' 
,$_SESSION'['$understands']' 
,$_SESSION'['$important1']' 
,$_SESSION'['$important2']' 
,$_SESSION'['$important3']' 
,$_SESSION'['$important4']' 
,$_SESSION'['$important5']' 
,$_SESSION'['$nameofsystems']' 
,$_SESSION'['$not_adopting_sys_1']' 
,$_SESSION'['$not_adopting_sys_2']' 
,$_SESSION'['$not_adopting_sys_3']' 
,$_SESSION'['$not_adopting_sys_4']' 
,$_SESSION'['$not_adopting_sys_5']' 
,$_SESSION'['$not_adopting_sys_6']' 
,$_SESSION'['$not_adopting_sys_7']' 
,$_SESSION'['$not_adopting_sys_8']' 

)" 
or die (mysql_error()); 

//execute query and store the result 

$res = mysql_query($sql,$connection); 
if ($res) { 
echo "Your survey has been submitted - thankyou<BR /><BR />"; 

} else { 
echo "There was a problem with your post - please click the previous button and try again or contact the system administrator: tez@mindseyemidlands.co.uk<BR /><BR />"; 
} 
?> 

Tis is really bugging me (pardon the pun). Thanks in advance

    Put } before the $sql statement...

      You didn't close { after this:

      if (isset($_POST['Submit'])) { 
      

        Ive closed the isset condition by adding a } on the last line of ym code but now
        i'm getting an error saying I have undefined indexes for each my of posted values:

        $contact = $_POST['contact'];
        $nameorg = $_POST['nameorg'];
        $telephone = $_POST['telephone'];
        $besttimecontact = $_POST['besttimecontact'];
        $address1 = $_POST['address1'];
        $address2 = $_POST['address2'];
        $town = $_POST['town'];
        $county = $_POST['county'];
        $postcode = $_POST['postcode'];
        $fax = $_POST['fax'];
        

        etc etc

          This is truly doing my head in as the only difference in my code compared to past scripts is the session array at the top. Ive had a look at all my other scripts and I cannot spot what im doing wrong. Ive checked all my field names are compatible.
          Does the order in which you post the fields have to be the same order as they appear in the form itself?

            The error message says this for all the posts:

            Notice: Undefined index: contact in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 21

            Notice: Undefined index: nameorg in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 22

            Notice: Undefined index: telephone in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 23

            Notice: Undefined index: address1 in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 24

            Notice: Undefined index: address2 in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 25

            Notice: Undefined index: town in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 26

            Notice: Undefined index: county in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 27

            Notice: Undefined index: postcode in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 28

            Notice: Undefined index: fax in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 29

            Notice: Undefined index: email in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 30

            Notice: Undefined index: website in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 31

            Notice: Undefined index: ethnicityusers in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 37

            Notice: Undefined index: activities in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 39

            Notice: Undefined index: beneficiaries in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 40

            Notice: Undefined index: legalstatus in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 42

            Notice: Undefined index: ft30plus in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 46

            Notice: Undefined index: pt16hrs in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 47

            Notice: Undefined index: pt1630hrs in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 48

            Notice: Undefined index: common_whatexpect in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 53

            Notice: Undefined index: reliable in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 54

            Notice: Undefined index: cheap in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 55

            Notice: Undefined index: personalservice in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 56

            Notice: Undefined index: slow in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 57

            Notice: Undefined index: qualifiedstaff_people in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 58

            Notice: Undefined index: widechoice in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 59

            Notice: Undefined index: consistent in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 60

            Notice: Undefined index: approachable in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 61

            Notice: Undefined index: fitforpurpose in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 62

            Notice: Undefined index: welleducated in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 63

            Notice: Undefined index: friendly in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 64

            Notice: Undefined index: prompt in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 65

            Notice: Undefined index: attentive in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 66

            Notice: Undefined index: speedy in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 67

            Notice: Undefined index: meetsneeds in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 68

            Notice: Undefined index: takeson in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 69

            Notice: Undefined index: providesxtras in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 70

            There was a problem with your post - please click the previous button and try again or contact the system administrator: tez@mindseyemidlands.co.uk

              Add The curly bracket after
              or die (mysql_error());

              <?php
              //open the db connection
              include("connect.php");
              //carry on the session array thats holding the data values
              session_start();
              foreach($_POST as $key => $val)
              {
              $_SESSION[$key] = $val;
              }
              
              if (isset($_POST['Submit'])) {
              
              $contact = $_POST['contact'];
              $nameorg = $_POST['nameorg'];
              $telephone = $_POST['telephone'];
              $besttimecontact = $_POST['besttimecontact'];
              $address1 = $_POST['address1'];
              $address2 = $_POST['address2'];
              $town = $_POST['town'];
              $county = $_POST['county'];
              $postcode = $_POST['postcode'];
              $fax = $_POST['fax'];
              $email = $_POST['email'];
              $website = $_POST['website'];
              $govoffreg = $_POST['govoffreg'];
              $premises = $_POST['premises'];
              $commitee = $_POST['commitee'];
              $fundingsources = $_POST['fundingsources'];
              $bmeorg = $_POST['bmeorg'];
              $ethnicityusers = $_POST['ethnicityusers'];
              $orgtype = $_POST['orgtype'];
              $activities = $_POST['activities'];
              $beneficiaries = $_POST['beneficiaries'];
              $contactrole = $_POST['contactrole'];
              $legalstatus = $_POST['legalstatus'];
              $levelorg = $_POST['levelorg'];
              $areaop = $_POST['areaop'];
              $income = $_POST['income'];
              $ft30plus = $_POST['ft30plus'];
              $pt16hrs = $_POST['pt16hrs'];
              $pt1630hrs = $_POST['pt1630hrs'];
              $sessional = $_POST['sessional'];
              $trainers = $_POST['trainers'];
              $unclassified = $_POST['unclassified'];
              $volunteer = $_POST['volunteer'];
              $common_whatexpect = $_POST['common_whatexpect'];
              $reliable = $_POST['reliable'];
              $cheap = $_POST['cheap'];
              $personalservice = $_POST['personalservice'];
              $slow = $_POST['slow'];
              $qualifiedstaff_people = $_POST['qualifiedstaff_people'];
              $widechoice = $_POST['widechoice'];
              $consistent = $_POST['consistent'];
              $approachable = $_POST['approachable'];
              $fitforpurpose = $_POST['fitforpurpose'];
              $welleducated = $_POST['welleducated'];
              $friendly = $_POST['friendly'];
              $prompt = $_POST['prompt'];
              $attentive = $_POST['attentive'];
              $speedy = $_POST['speedy'];
              $meetsneeds = $_POST['meetsneeds'];
              $takeson = $_POST['takeson'];
              $providesxtras = $_POST['providesxtras'];
              $handson = $_POST['handson'];
              $responsive = $_POST['responsive'];
              $ltdselection = $_POST['ltdselection'];
              $competent = $_POST['competent'];
              $affordable = $_POST['affordable'];
              $accessible = $_POST['accessible'];
              $knowledgeable = $_POST['knowledgeable'];
              $checkssatisfaction = $_POST['checkssatisfaction'];
              $getsdetails = $_POST['getsdetails'];
              $understands = $_POST['understands'];
              $important1 = $_POST['important1'];
              $important2 = $_POST['important2'];
              $important3 = $_POST['important3'];
              $important4 = $_POST['important4'];
              $important5 = $_POST['important5'];
              $nameofsystems = $_POST['nameofsystems'];
              $not_adopting_sys_1 = $_POST['not_adopting_sys_1'];
              $not_adopting_sys_2 = $_POST['not_adopting_sys_2'];
              $not_adopting_sys_3 = $_POST['not_adopting_sys_3'];
              $not_adopting_sys_4 = $_POST['not_adopting_sys_4'];
              $not_adopting_sys_5 = $_POST['not_adopting_sys_5'];
              $not_adopting_sys_6 = $_POST['not_adopting_sys_6'];
              $not_adopting_sys_7 = $_POST['not_adopting_sys_7'];
              $not_adopting_sys_8 = $_POST['not_adopting_sys_8'];
              
              $sql = "INSERT INTO nottsvcs (contact, nameorg, telephone, besttimecontact
              ,address1
              ,address2
              ,town
              ,county
              ,postcode
              ,fax
              ,email
              ,website
              ,govoffreg
              ,premises
              ,commitee
              ,fundingsources
              ,bmeorg
              ,ethnictyusers
              ,orgtype
              ,activities
              ,beneficiaries
              ,contactrole
              ,legalstatus
              ,levelorg
              ,areaop
              ,incomeft30plus
              ,pt16hrs
              ,pt1630hrs
              ,sessional
              ,trainers
              ,unclassified
              ,volunteer
              ,common_whatexpec
              ,reliable
              ,cheap
              ,personalservice
              ,slow
              ,qualifiedstaff_people
              ,widechoice
              ,consistent
              ,approachable
              ,fitforpurpose
              ,welleducated
              ,friendly
              ,prompt
              ,attentive
              ,speedy
              ,meetsneeds
              ,takeson
              ,providesxtras
              ,handson
              ,responsive
              ,ltdselection
              ,competent
              ,affordable
              ,accessible
              ,knowledgeable
              ,checkssatisfaction
              ,getsdetails
              ,understands
              ,important1
              ,important2
              ,important3
              ,important4
              ,important5
              ,nameofsystems
              ,not_adopting_sys_1
              ,not_adopting_sys_2
              ,not_adopting_sys_3
              ,not_adopting_sys_4
              ,not_adopting_sys_5
              ,not_adopting_sys_6
              ,not_adopting_sys_7
              ,not_adopting_sys_8)
              
              
              VALUES ($_SESSION'['$contact']'
              ,$_SESSION'['$nameorg']'
              ,$_SESSION'['$telephone']'
              ,$_SESSION'['$besttimecontact']'
              ,$_SESSION'['$address1']'
              ,$_SESSION'['$address2']'
              ,$_SESSION'['$town']'
              ,$_SESSION'['$county']'
              ,$_SESSION'['$postcode']'
              ,$_SESSION'['$fax']'
              ,$_SESSION'['$email']'
              ,$_SESSION'['$website']'
              ,$_SESSION'['$govoffreg']'
              ,$_SESSION'['$premises']'
              ,$_SESSION'['$commitee']'
              ,$_SESSION'['$fundingsources']'
              ,$_SESSION'['$bmeorg']'
              ,$_SESSION'['$ethnictyusers']'
              ,$_SESSION'['$orgtype']'
              ,$_SESSION'['$activities']'
              ,$_SESSION'['$beneficiaries']'
              ,$_SESSION'['$contactrole']'
              ,$_SESSION'['$legalstatus']'
              ,$_SESSION'['$levelorg']'
              ,$_SESSION'['$areaop']'
              ,$_SESSION'['$income']'
              ,$_SESSION'['$ft30plus']'
              ,$_SESSION'['$pt16hrs']'
              ,$_SESSION'['$pt1630hrs']'
              ,$_SESSION'['$sessional']'
              ,$_SESSION'['$trainers']'
              ,$_SESSION'['$unclassified']'
              ,$_SESSION'['$volunteer']'
              ,$_SESSION'['$common_whatexpect']'
              ,$_SESSION'['$reliable']'
              ,$_SESSION'['$cheap']'
              ,$_SESSION'['$personalservice']'
              ,$_SESSION'['$slow']'
              ,$_SESSION'['$qualifiedstaff_people']'
              ,$_SESSION'['$widechoice']'
              ,$_SESSION'['$consistent']'
              ,$_SESSION'['$approachable']'
              ,$_SESSION'['$fitforpurpose']'
              ,$_SESSION'['$welleducated']'
              ,$_SESSION'['$friendly']'
              ,$_SESSION'['$prompt']'
              ,$_SESSION'['$attentive']'
              ,$_SESSION'['$speedy']'
              ,$_SESSION'['$meetsneeds']'
              ,$_SESSION'['$takeson']'
              ,$_SESSION'['$providesxtras']'
              ,$_SESSION'['$handson']'
              ,$_SESSION'['$responsive']'
              ,$_SESSION'['$ltdselection']'
              ,$_SESSION'['$competent']'
              ,$_SESSION'['$affordable']'
              ,$_SESSION'['$accessible']'
              ,$_SESSION'['$knowledgeable']'
              ,$_SESSION'['$checkssatisfaction']'
              ,$_SESSION'['$getsdetails']'
              ,$_SESSION'['$understands']'
              ,$_SESSION'['$important1']'
              ,$_SESSION'['$important2']'
              ,$_SESSION'['$important3']'
              ,$_SESSION'['$important4']'
              ,$_SESSION'['$important5']'
              ,$_SESSION'['$nameofsystems']'
              ,$_SESSION'['$not_adopting_sys_1']'
              ,$_SESSION'['$not_adopting_sys_2']'
              ,$_SESSION'['$not_adopting_sys_3']'
              ,$_SESSION'['$not_adopting_sys_4']'
              ,$_SESSION'['$not_adopting_sys_5']'
              ,$_SESSION'['$not_adopting_sys_6']'
              ,$_SESSION'['$not_adopting_sys_7']'
              ,$_SESSION'['$not_adopting_sys_8']'
              
              )"
              or die (mysql_error());
              
              }
              //execute query and store the result
              
              $res = mysql_query($sql,$connection);
              if ($res) {
              echo "Your survey has been submitted - thankyou<BR /><BR />";
              
              } else {
              echo "There was a problem with your post - please click the previous button and try again or contact the system administrator: tez@mindseyemidlands.co.uk<BR /><BR />";
              }
              
              ?> 

                I changed the position of the curly bracket as suggested but
                error message as says:

                Parse error: parse error, unexpected '}' in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 744

                  You have "or die (mysql_error());"

                  After your SQL statement...

                  However, your sql statement is only a variable.. you forgot the 'mysql_query("");' part

                  change this:
                  ,$_SESSION'['$not_adopting_sys_8']'

                  )"
                  or die (mysql_error());

                  to this:
                  ,$_SESSION'['$not_adopting_sys_8']'

                  )";

                  mysql_query($sql) or die (mysql_error());

                    Your problem with the undefined indexes is because THEY DO NOT EXIST in $_POST.

                    You are taking data from page 1 of your form and saving it in $SESSION, same for page 2 and 3.
                    You are doing this because the input from page 1 will be lost when you move to page 2 and so on.
                    So on page 4 you have to extract the saved data from $
                    SESSION not from $POST because it IS NOT IN $POST, hence the undefined index error.

                    By the way, I thought we had already gone through all this elsewhere?

                      To extract the data from $session as opposed to $post do I simply replace $post i.e:

                      if (isset($_SESSION['Submit']))

                      $contact = $SESSION['contact'];
                      $nameorg = $
                      SESSION['nameorg'];
                      $telephone = $SESSION['telephone'];
                      $address1 = $
                      SESSION['address1'];
                      $address2 = $_SESSION['address2'];

                      ??????

                        Yes Roger we spoke about this:

                        http://phpbuilder.com/board/showthread.php?t=10312697

                        but the quote_smart approach was not working out. I read up on the link but couldn't figure out how to make use of thr best practice.
                        I reposted as I had different error messages but now ive come back to the same problem.

                        I have just tried your suggestion in the other thread again with the following which comes out with an undefined variable error:

                        Notice: Undefined variable: besttimecontact in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 257

                        here is my code:

                        <?php 
                        session_start(); 
                        foreach($_POST as $key => $val) 
                        { 
                        $_SESSION[$key] = $val; 
                        } 
                        
                        
                        //open the db connection 
                        include("connect.php"); 
                        
                        if (isset($_POST['Submit'])) 
                        
                        $sql = "INSERT INTO nottsvcs (contact, nameorg, telephone, besttimecontact
                        ,address1
                        ,address2
                        ,town
                        ,county
                        ,postcode
                        ,fax
                        ,email
                        ,website
                        ,govoffreg
                        ,premises
                        ,commitee
                        ,fundingsources
                        ,bmeorg
                        ,ethnictyusers
                        ,orgtype
                        ,activities
                        ,beneficiaries
                        ,contactrole
                        ,legalstatus
                        ,levelorg
                        ,areaop
                        ,incomeft30plus
                        ,pt16hrs
                        ,pt1630hrs
                        ,sessional
                        ,trainers
                        ,unclassified
                        ,volunteer
                        ,common_whatexpec
                        ,reliable
                        ,cheap
                        ,personalservice
                        ,slow
                        ,qualifiedstaff_people
                        ,widechoice
                        ,consistent
                        ,approachable
                        ,fitforpurpose
                        ,welleducated
                        ,friendly
                        ,prompt
                        ,attentive
                        ,speedy
                        ,meetsneeds
                        ,takeson
                        ,providesxtras
                        ,handson
                        ,responsive
                        ,ltdselection
                        ,competent
                        ,affordable
                        ,accessible
                        ,knowledgeable
                        ,checkssatisfaction
                        ,getsdetails
                        ,understands
                        ,important1
                        ,important2
                        ,important3
                        ,important4
                        ,important5
                        ,nameofsystems
                        ,not_adopting_sys_1
                        ,not_adopting_sys_2
                        ,not_adopting_sys_3
                        ,not_adopting_sys_4
                        ,not_adopting_sys_5
                        ,not_adopting_sys_6
                        ,not_adopting_sys_7
                        ,not_adopting_sys_8
                        ,list_quality_sys_1
                        ,list_quality_sys_2
                        ,list_quality_sys_3
                        ,list_quality_sys_4
                        ,list_quality_sys_5
                        ,list_quality_sys_6
                        ,list_quality_sys_7
                        ,list_quality_sys_8
                        ,list_quality_sys_9
                        ,list_quality_sys_10
                        ,list_quality_sys_11
                        ,list_quality_sys_12
                        ,list_quality_sys_13
                        ,list_quality_sys_14
                        ,list_quality_sys_15
                        ,list_quality_sys_16
                        ,list_quality_sys_17
                        ,list_quality_sys_18
                        ,list_quality_sys_19
                        ,list_quality_sys_20
                        ,list_quality_sys_21
                        ,list_quality_sys_22
                        ,list_quality_sys_23
                        ,list_quality_sys_24
                        ,list_quality_sys_25
                        ,list_quality_sys_26
                        ,list_quality_sys_27
                        ,list_quality_sys_28
                        ,list_quality_sys_29
                        ,list_quality_sys_30
                        ,list_quality_sys_31
                        ,list_quality_sys_32
                        ,list_quality_sys_33
                        ,list_quality_sys_34
                        ,list_quality_sys_35
                        ,list_quality_sys_36
                        ,list_quality_sys_37
                        ,list_quality_sys_38
                        ,list_quality_sys_39
                        ,list_quality_sys_40
                        ,list_quality_sys_41
                        ,list_quality_sys_42
                        ,list_quality_sys_43
                        ,list_quality_sys_44
                        ,list_quality_sys_45
                        ,list_quality_sys_46
                        ,list_quality_sys_47
                        ,list_quality_sys_48
                        ,list_quality_sys_49
                        ,list_quality_sys_50
                        ,list_quality_sys_51
                        ,list_quality_sys_52
                        ,list_quality_sys_53
                        ,list_quality_sys_54
                        ,list_quality_sys_55
                        ,list_quality_sys_56
                        ,list_quality_sys_57
                        ,list_quality_sys_58
                        ,how_you_feel_1
                        ,how_you_feel_2
                        ,how_you_feel_3
                        ,how_you_feel_4
                        ,how_you_feel_5
                        ,how_you_feel_6
                        ,how_you_feel_7
                        ,how_you_feel_8
                        ,how_you_feel_9
                        ,clear_view_plan
                        ,features_quality_rate_1
                        ,features_quality_rate_2
                        ,features_quality_rate_3
                        ,features_quality_rate_4
                        ,features_quality_rate_5
                        ,features_quality_rate_6
                        ,features_quality_rate_7
                        ,features_quality_rate_8
                        ,features_quality_rate_9
                        ,features_quality_rate_10
                        ,features_quality_rate_11
                        ,features_quality_rate_12
                        ,features_quality_rate_others)
                        
                        VALUES ($_SESSION'['$contact']'
                        ,$_SESSION'['$nameorg']'
                        ,$_SESSION'['$telephone']' 
                        ,$_SESSION'['$besttimecontact']'
                        ,$_SESSION'['$address1']' 
                        ,$_SESSION'['$address2']'
                        ,$_SESSION'['$town']'
                        ,$_SESSION'['$county']'
                        ,$_SESSION'['$postcode']'
                        ,$_SESSION'['$fax']'
                        ,$_SESSION'['$email']'
                        ,$_SESSION'['$website']'
                        ,$_SESSION'['$govoffreg']'
                        ,$_SESSION'['$premises']'
                        ,$_SESSION'['$commitee']'
                        ,$_SESSION'['$fundingsources']'
                        ,$_SESSION'['$bmeorg']'
                        ,$_SESSION'['$ethnictyusers']'
                        ,$_SESSION'['$orgtype']'
                        ,$_SESSION'['$activities']'
                        ,$_SESSION'['$beneficiaries']'
                        ,$_SESSION'['$contactrole']'
                        ,$_SESSION'['$legalstatus']'
                        ,$_SESSION'['$levelorg']'
                        ,$_SESSION'['$areaop']'
                        ,$_SESSION'['$income']'
                        ,$_SESSION'['$ft30plus']'
                        ,$_SESSION'['$pt16hrs']'
                        ,$_SESSION'['$pt1630hrs']'
                        ,$_SESSION'['$sessional']'
                        ,$_SESSION'['$trainers']'
                        ,$_SESSION'['$unclassified']'
                        ,$_SESSION'['$volunteer']'
                        ,$_SESSION'['$common_whatexpect']'
                        ,$_SESSION'['$reliable']'
                        ,$_SESSION'['$cheap']'
                        ,$_SESSION'['$personalservice']'
                        ,$_SESSION'['$slow']'
                        ,$_SESSION'['$qualifiedstaff_people']'
                        ,$_SESSION'['$widechoice']'
                        ,$_SESSION'['$consistent']'
                        ,$_SESSION'['$approachable']'
                        ,$_SESSION'['$fitforpurpose']'
                        ,$_SESSION'['$welleducated']'
                        ,$_SESSION'['$friendly']'
                        ,$_SESSION'['$prompt']'
                        ,$_SESSION'['$attentive']'
                        ,$_SESSION'['$speedy']'
                        ,$_SESSION'['$meetsneeds']'
                        ,$_SESSION'['$takeson']'
                        ,$_SESSION'['$providesxtras']'
                        ,$_SESSION'['$handson']'
                        ,$_SESSION'['$responsive']'
                        ,$_SESSION'['$ltdselection']'
                        ,$_SESSION'['$competent']'
                        ,$_SESSION'['$affordable']'
                        ,$_SESSION'['$accessible']'
                        ,$_SESSION'['$knowledgeable']'
                        ,$_SESSION'['$checkssatisfaction']'
                        ,$_SESSION'['$getsdetails']'
                        ,$_SESSION'['$understands']'
                        ,$_SESSION'['$important1']'
                        ,$_SESSION'['$important2']'
                        ,$_SESSION'['$important3']'
                        ,$_SESSION'['$important4']'
                        ,$_SESSION'['$important5']'
                        ,$_SESSION'['$nameofsystems']'
                        ,$_SESSION'['$not_adopting_sys_1']'
                        ,$_SESSION'['$not_adopting_sys_2']'
                        ,$_SESSION'['$not_adopting_sys_3']'
                        ,$_SESSION'['$not_adopting_sys_4']'
                        ,$_SESSION'['$not_adopting_sys_5']'
                        ,$_SESSION'['$not_adopting_sys_6']'
                        ,$_SESSION'['$not_adopting_sys_7']'
                        ,$_SESSION'['$not_adopting_sys_8']'
                        ,$_SESSION'['$list_quality_sys_1']'
                        ,$_SESSION'['$list_quality_sys_2']'
                        ,$_SESSION'['$list_quality_sys_3']'
                        ,$_SESSION'['$list_quality_sys_4']'
                        ,$_SESSION'['$list_quality_sys_5']'
                        ,$_SESSION'['$list_quality_sys_6']'
                        ,$_SESSION'['$list_quality_sys_7']'
                        ,$_SESSION'['$list_quality_sys_8']'
                        ,$_SESSION'['$list_quality_sys_9']'
                        ,$_SESSION'['$list_quality_sys_10']'
                        ,$_SESSION'['$list_quality_sys_11']'
                        ,$_SESSION'['$list_quality_sys_12']'
                        ,$_SESSION'['$list_quality_sys_13']'
                        ,$_SESSION'['$list_quality_sys_14']'
                        ,$_SESSION'['$list_quality_sys_15']'
                        ,$_SESSION'['$list_quality_sys_16']'
                        ,$_SESSION'['$list_quality_sys_17']'
                        ,$_SESSION'['$list_quality_sys_18']'
                        ,$_SESSION'['$list_quality_sys_19']'
                        ,$_SESSION'['$list_quality_sys_20']'
                        ,$_SESSION'['$list_quality_sys_21']'
                        ,$_SESSION'['$list_quality_sys_22']'
                        ,$_SESSION'['$list_quality_sys_23']'
                        ,$_SESSION'['$list_quality_sys_24']'
                        ,$_SESSION'['$list_quality_sys_25']'
                        ,$_SESSION'['$list_quality_sys_26']'
                        ,$_SESSION'['$list_quality_sys_27']'
                        ,$_SESSION'['$list_quality_sys_28']'
                        ,$_SESSION'['$list_quality_sys_29']'
                        ,$_SESSION'['$list_quality_sys_30']'
                        ,$_SESSION'['$list_quality_sys_31']'
                        ,$_SESSION'['$list_quality_sys_32']'
                        ,$_SESSION'['$list_quality_sys_33']'
                        ,$_SESSION'['$list_quality_sys_34']'
                        ,$_SESSION'['$list_quality_sys_35']'
                        ,$_SESSION'['$list_quality_sys_36']'
                        ,$_SESSION'['$list_quality_sys_37']'
                        ,$_SESSION'['$list_quality_sys_38']'
                        ,$_SESSION'['$list_quality_sys_39']'
                        ,$_SESSION'['$list_quality_sys_40']'
                        ,$_SESSION'['$list_quality_sys_41']'
                        ,$_SESSION'['$list_quality_sys_42']'
                        ,$_SESSION'['$list_quality_sys_43']'
                        ,$_SESSION'['$list_quality_sys_44']'
                        ,$_SESSION'['$list_quality_sys_45']'
                        ,$_SESSION'['$list_quality_sys_46']'
                        ,$_SESSION'['$list_quality_sys_47']'
                        ,$_SESSION'['$list_quality_sys_48']'
                        ,$_SESSION'['$list_quality_sys_49']'
                        ,$_SESSION'['$list_quality_sys_50']'
                        ,$_SESSION'['$list_quality_sys_51']'
                        ,$_SESSION'['$list_quality_sys_52']'
                        ,$_SESSION'['$list_quality_sys_53']'
                        ,$_SESSION'['$list_quality_sys_54']'
                        ,$_SESSION'['$list_quality_sys_55']'
                        ,$_SESSION'['$list_quality_sys_56']'
                        ,$_SESSION'['$list_quality_sys_57']'
                        ,$_SESSION'['$list_quality_sys_58']'
                        ,$_SESSION'['$how_you_feel_1']'
                        ,$_SESSION'['$how_you_feel_2']'
                        ,$_SESSION'['$how_you_feel_3']'
                        ,$_SESSION'['$how_you_feel_4']'
                        ,$_SESSION'['$how_you_feel_5']'
                        ,$_SESSION'['$how_you_feel_6']'
                        ,$_SESSION'['$how_you_feel_7']'
                        ,$_SESSION'['$how_you_feel_8']'
                        ,$_SESSION'['$how_you_feel_9']'
                        ,$_SESSION'['$clear_view_plan']'
                        ,$_SESSION'['$features_quality_rate_1']'
                        ,$_SESSION'['$features_quality_rate_2']'
                        ,$_SESSION'['$features_quality_rate_3']'
                        ,$_SESSION'['$features_quality_rate_4']'
                        ,$_SESSION'['$features_quality_rate_5']'
                        ,$_SESSION'['$features_quality_rate_6']'
                        ,$_SESSION'['$features_quality_rate_7']'
                        ,$_SESSION'['$features_quality_rate_8']'
                        ,$_SESSION'['$features_quality_rate_9']'
                        ,$_SESSION'['$features_quality_rate_10']'
                        ,$_SESSION'['$features_quality_rate_11']'
                        ,$_SESSION'['$features_quality_rate_12']'
                        ,$_SESSION'['$features_quality_rate_others']'
                        
                        )";
                        
                        mysql_query($sql) or die (mysql_error());
                        
                        
                        //execute query and store the result
                        
                        $res = mysql_query($sql,$connection);
                        if ($res) {
                        echo "Your survey has been submitted - thankyou<BR /><BR />";
                        
                        } else {
                        echo "There was a problem with your post - please click the previous button and try again or contact the system administrator: tez@mindseyemidlands.co.uk<BR /><BR />";
                        }
                        
                        ?>
                        

                        I cannot win either way at the moment as this creates an undefined variable error and if I do it the other way with POST then I have undefined indexes

                          What are you trying to write in here?

                          VALUES ($_SESSION'['$contact']'
                          ,$_SESSION'['$nameorg']'
                          ,$_SESSION'['$telephone']' 
                          //etc
                          

                          If I know anything about PHP I can see that this is way wrong... It should be:

                          VALUES ('$_SESSION[contact]'
                          ,'$_SESSION[nameorg]'
                          ,'$_SESSION[telephone]' 
                          //etc
                          

                          ...but only if contact, nameorg, telephone etc. are values you gather from the form (are field names in the form) i.e. are present in the $_POST array where they are represented as $POST['contact'], $POST['nameorg'] etc. And after that litle piece of code that transfroms these into session variables they become $SESSION['contact'], $SESSION['nameorg'] etc.

                          Quotes go on the outside of the value that you try to implement into SQL query and thus they all become '$_SESSION[contact]' and such...

                          Hope this is helpful in any way...

                            Tezread wrote:

                            To extract the data from $session as opposed to $post do I simply replace $post i.e:

                            if (isset($_SESSION['Submit']))

                            $contact = $SESSION['contact'];
                            $nameorg = $
                            SESSION['nameorg'];
                            $telephone = $SESSION['telephone'];
                            $address1 = $
                            SESSION['address1'];
                            $address2 = $_SESSION['address2'];

                            ??????

                            Yes, that is exactly right. I copy/pasted from your code and forgot to take out the $ signs - see my signature.

                            Now, for some reason my last post in the other thread has not shown up??? In it I showed you how I personally handle stuff like this; so here goes again.

                            Since you are just after building a query string from all these vars, you can automate the process a lot instead of typing out all those var names.

                            // at the top of each form processing page you need this little bit of code
                            
                            require_once('common_functions.php');     // includes the quote_smart function
                            
                            if (isset($_POST['submit'])) {
                            
                            foreach ($_POST as $key=>$val) {
                            
                            // build the column name list
                            $_SESSION['cols'] .= $key . ',';
                            // and the values list
                            $_SESSION['vals'] .= quote_smart($val) . ',';  
                            // and you MUST quote_smart to get the correct quotes around the values or the final query will fail } } // then in the form processing script you just need to clean up these 2 string and insert them into the query string $strcols = rtrim($_SESSION['cols'], ','); // remove final comma $strvals = rtrim($_SESSION['vals'], ','); $sql = "INSERT INTO nottsvcs (" . $strcols . ") VALUES (" . $strvals . ")"; echo $sql; // to see the query string you've built

                            This method saves a lot of typing, and will not need alteration if you add or remove fields in the forms. I have not included any form validation for required fields, required data types etc to keep things simple, but data validation should always be done somewhere.

                              Looks impressive- what is happening inside common_functions.php.?

                              Also im not sure how to how to go about cleaning up the strings you refer to.

                              // then in the form processing script you just need to clean up these 2 string and insert them into the query string 
                              
                              $strcols = rtrim($_SESSION['cols'], ',');  // remove final comma 
                              $strvals = rtrim($_SESSION['vals'], ','); 
                              

                              As it stands I get the Undefined error message again- im confused as to how to rectify as your solution avoids using that long list of vars which is a good thing

                                Roger- thankyou for all your help by the way.
                                This is a dynamic approach as you can add fields to the forms easily plus the added security is a bonus with the quote_smart function.
                                I hope I have interpreted your code correctly as I have an error message now:

                                Notice: Undefined variable: _SESSION in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 7

                                Notice: Undefined variable: _SESSION in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 8
                                INSERT INTO nottsvcs () VALUES ()

                                This is the code I have a the top of each of the forms:

                                <?php
                                // at the top of each form processing page you need this little bit of code 
                                
                                require_once('common_functions.php'); // includes the quote_smart function 
                                
                                if (isset($_POST['submit'])) { 
                                
                                foreach ($_POST as $key=>$val) { 
                                
                                // build the column name list 
                                $_SESSION['cols'] .= $key . ','; 
                                // and the values list 
                                $_SESSION['vals'] .= quote_smart($val) . ','; 
                                
                                } 
                                } 
                                
                                
                                ?>
                                

                                This is the final formhandler:

                                
                                <?php
                                include("connect.php");
                                
                                
                                $strcols = rtrim($_SESSION['cols'], ',');  
                                $strvals = rtrim($_SESSION['vals'], ','); $sql = "INSERT INTO nottsvcs (" . $strcols . ") VALUES (" . $strvals . ")"; echo $sql;
                                ?>

                                  Those error messages look like you have a typo or two

                                  SESSION not $SESSION

                                  Are you sure you are pasting the code exactly as you are using it?

                                  One thing occurs to me though: when concatenating each value to the existing string $_SESSION['vals'], php may loose the quotes around string entries cos it's concating a string to a string. If it does then just amend the code to

                                  $_SESSION['vals'] .= "'" . quote_smart($val) . "',";
                                  

                                  That should embed the single quotes around the strings that sql requires.

                                  Correction, you are missing the session_start() at the top of formhandler.

                                    I am agonizingly close to success here. I get an error message stating:

                                    Parse error: parse error, unexpected '[' in /disk1/home3/mindseye/public_html/nottsvcs_short_1_4_formhandler.php on line 19

                                    I took replaced $SESSION and made this into SESSION though this has caused the error message above. Since reading your last post ive spent almost 2 hours looking up the error message above but it is not mentioned on this forum alas.

                                    Here is my final formhander:

                                    
                                    <?php 
                                    session_start();
                                    
                                    require_once('common_functions.php'); // includes the quote_smart function 
                                    
                                    if (isset($_POST['submit'])) { 
                                    
                                    foreach ($_POST as $key=>$val) { 
                                    
                                    // build the column name list 
                                    $_SESSION['cols'] .= $key . ','; 
                                    // and the values list 
                                    $_SESSION['vals'] .= quote_smart($val) . ','; 
                                    
                                    } 
                                    } 
                                    include("connect.php"); 
                                    // this is where I replaced $_SESSION for _SESSION
                                    
                                    $strcols = rtrim(_SESSION['cols'], ',');   
                                    $strvals = rtrim(_SESSION['vals'], ','); $sql = "INSERT INTO nottsvcs (" . $strcols . ") VALUES (" . $strvals . ")"; echo $sql; ?>

                                    Here is the common_functions.php code

                                    <?php
                                    function quote_smart($val) { 
                                    session_start(); 
                                    foreach($_POST as $key => $val) 
                                    { 
                                    $_SESSION[$key] = quote_smart($val);      
                                    } } ?>

                                      Your error message is because you tok the $ off the front of $SESSION. $SESSION is an array so the [] are expected. _SESSIOn on the other hand is just declaring a new var and [] are not permitted in var names. Put the $ signs back

                                      $strcols = rtrim($_SESSION['cols'], ',');   
                                      $strvals = rtrim($_SESSION['vals'], ','); //now echo them just for debugging echo $strcols; echo $strvals; //remove the echos once it is working

                                      Now, your common functions is all to pot. I always have a file called common.php in which I have the functions that I will use on almost every web site and script. I have copied and pasted the quote_smart function directly from the manual without alteration. Just use it as is. Copy the whole thing into your editor and save the file - this is a complete file from <? to ?>.

                                      
                                      <?php   
                                      
                                      // Quote variable to make safe
                                      function quote_smart($value)
                                      {
                                         // Stripslashes
                                         if (get_magic_quotes_gpc()) {
                                             $value = stripslashes($value);
                                         }
                                         // Quote if not integer
                                         if (!is_numeric($value)) {
                                             $value = "'" . mysql_real_escape_string($value) . "'";
                                         }
                                         return $value;
                                      }
                                      ?>