Jump to content

problem processing this form?


law

Recommended Posts

This is a from that can be edited in a database to change the form names and ect. The problem is that im doing something wrong to pull all of the variables.. soo when the form actually tries to insert into the table.. all of the values are not with their correct variables.. or not included at all.. i have just been looking at this for the last day and i need some time away from the code! if anyone spots the mistake please let me know... here is the error im getting after i try to submit the form!

 

-- -- 1 -- -- slot12 -- -- slot23 -- -- slot34 -- -- slot45 -- -- slot56 -- -- slot67 -- -- slot78 -- -- slot89 -- -- 10 -- -- 11 -- -- 12 -- -- 13 -- -- 14 -- -- 15 -- -- 16 -- -- 17 -- -- 18 -- -- 19 -- -- 20 -- -- 21 -- -- 22 -- -- 23 -- -- 24 -- -- 25 -- -- 26 -- -- 27 -- -- 28 -- -- 29 -- -- 30 -- -- MySQL ERROR: INSERT INTO userinfo (slot1,slot2,slot3,slot4,slot5,slot6,slot7,slot8,slot9,slot10, slot11,slot12,slot13,slot14,slot15,slot16,slot17,slot18,slot19,slot20, slot21,slot22,slot23,slot24,slot25,slot26,slot27,slot28,slot29,slot30, check1,check2,check3,check4,check5,check6,check7,check8,check9,check10, check11,check12,check13,check14,check15,check16,check17,check18,check19,check20, check21,check22,check23,check24,check25,check26,check27,check28,check29,check30,) VALUES ('slotv[1]','slotv[2]','slotv[3]','slotv[4]','slotv[5]','slotv[6]','slotv[7]','slotv[8]','slotv[9]','slotv[10]', 'slotv[11]','slotv[12]','slotv[13]','slotv[14]','slotv[15]','slotv[16]','slotv[17]','slotv[18]','slotv[19]','slotv[20]', 'slotv[21]','slotv[22]','slotv[23]','slotv[24]','slotv[25]','slotv[26]','slotv[27]','slotv[28]','slotv[29]','slotv[30]', 'checkv[1]','checkv[2]','checkv[3]','checkv[4]','checkv[5]','checkv[6]','checkv[7]','checkv[8]','checkv[9]','checkv[10]', 'checkv[11]','checkv[12]','checkv[13]','checkv[14]','checkv[15]','checkv[16]','checkv[17]','checkv[18]','checkv[19]','checkv[20]', 'checkv[21]','checkv[22]','checkv[23]','checkv[24]','checkv[25]','checkv[26]','checkv[27]','checkv[28]','checkv[29]','checkv[30]')
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 ') VALUES ('slotv[1]','slotv[2]','slotv[3]','slotv[4]','slotv[5]','slotv[6]' at line 6

 

<html>
<head>
<title>
</title>
</head>
<body>
<?php
include_once("./dbconfig.php");
//=======================================FORM PROCESSOR=========================================
$i=0;
while($i<=30){
$slotvar[$i] = "slot".$i;
$slotv[$i] = mysql_escape_string($_POST[$slotvar[$i]]);
$checkvar[$i] = "check".$i;
$checkv[$i] = mysql_escape_string($_POST[$checkvar[$i]]);	
echo"$i -- $checkv[$i] -- $slotv[$i]";
$i++;
}
if ($_GET['submitted']==1){
$query = "INSERT INTO userinfo (slot1,slot2,slot3,slot4,slot5,slot6,slot7,slot8,slot9,slot10,
				slot11,slot12,slot13,slot14,slot15,slot16,slot17,slot18,slot19,slot20,
				slot21,slot22,slot23,slot24,slot25,slot26,slot27,slot28,slot29,slot30,
				check1,check2,check3,check4,check5,check6,check7,check8,check9,check10,
				check11,check12,check13,check14,check15,check16,check17,check18,check19,check20,
				check21,check22,check23,check24,check25,check26,check27,check28,check29,check30,) 
			VALUES ('slotv[1]','slotv[2]','slotv[3]','slotv[4]','slotv[5]','slotv[6]','slotv[7]','slotv[8]','slotv[9]','slotv[10]',
				'slotv[11]','slotv[12]','slotv[13]','slotv[14]','slotv[15]','slotv[16]','slotv[17]','slotv[18]','slotv[19]','slotv[20]',
				'slotv[21]','slotv[22]','slotv[23]','slotv[24]','slotv[25]','slotv[26]','slotv[27]','slotv[28]','slotv[29]','slotv[30]',
				'checkv[1]','checkv[2]','checkv[3]','checkv[4]','checkv[5]','checkv[6]','checkv[7]','checkv[8]','checkv[9]','checkv[10]',
				'checkv[11]','checkv[12]','checkv[13]','checkv[14]','checkv[15]','checkv[16]','checkv[17]','checkv[18]','checkv[19]','checkv[20]',
				'checkv[21]','checkv[22]','checkv[23]','checkv[24]','checkv[25]','checkv[26]','checkv[27]','checkv[28]','checkv[29]','checkv[30]')";
$result = mysql_query($query) or die("MySQL ERROR: $query <br> ".mysql_error());
echo "<font color=orange><b>$slotvv[1] was successfully added.</b></font><br/>";
}
//=======================================--------------=========================================
//===================================================Querys=====================================
$fieldq="SELECT * FROM fieldnames WHERE id = 1";
$fieldsql=mysql_query($fieldq);
$fieldrow = mysql_fetch_array($fieldsql);

//------------------TITLES and IMAGES------------
$checkboxtitle = array();
for ($num=1;$num<3;$num++){
   $checkboxtitle[$num] = $fieldrow['checkboxtitle' . $num];
}
//---------------------------------------
$image = array();
for ($num=1;$num<4;$num++){
   $image[$num] = $fieldrow['image' . $num];
}
$title = $fieldrow[title]; 
//-----------------==================-------------
//===================================================------=====================================

echo "<table align=center>
<tr valign=top>
<td valign=top>";

echo "<form name='infosubmission' action='./index.php?submitted=1' method='post' enctype='multipart/form-data'>
<table border=0 align=center height=850 width=850 bgcolor=orange><CAPTION ALIGN=TOP><B>CSA Student Information System</B></CAPTION>
<tr align=center>
<td align=right colspan=2>$image1</td>
<td colspan=2><b>$title</b></td>
<td align=left colspan=2>$image2</td>
</tr>
<tr align=center>";
//-------------===========------------==========---------- Slots 1-15 ---------==============
$i=1;
$slot = array();
for ($num=1;$num<16;$num++){
   $slot[$num] = $fieldrow['slot' . $num];
if ($slot[$num] !== null){
echo "<td colspan=2><font size=3>$slot[$num]: </font><input class='form-input-field' type='text' name='slot$num' value='slot$num' size='20' /></td>";
}
if ($i == 3){
echo "</tr> <tr align=center>";
$i=0;
}	
$i++;
}
//-------------===========------------==========---------- Checkboxes 1-20 ---------==============
echo "</tr><tr><td rowspan=4 align=right><b>
$checkboxtitle[1]:
	</b></td><tr>";
$i=1;
$check = array();
for ($num=1;$num<21;$num++){
   $check[$num] = $fieldrow['check' . $num];
if ($check[$num] !== null){
echo "<td align=center>$check[$num] <input type='checkbox' name='check[$num]' value='yes'/></td>";
}
if ($i == 4){
echo "</tr> <tr align=center>";
$i=0;
}
$i++;
}
//-------------===========------------==========---------- Slots 15-30 ---------==============
echo "</tr> <tr>";
$i=1;
$slot = array();
for ($num=16;$num<31;$num++){
   $slot[$num] = $fieldrow['slot' . $num];
if ($slot[$num] !== null){
echo "<td colspan=2><font size=3>$slot[$num]: <input class='form-input-field' type='text' name='slot[$num]' size='20' /></td>";
}
if ($i == 3){
echo "</tr> <tr align=center>";
$i=0;
}
$i++;
}
//-------------===========------------==========---------- Checkboxes 21-40 ---------==============
echo "</tr><tr><td rowspan=4 align=right><b>
$checkboxtitle[2]:
	</b></td><tr>";
$i=1;
$check = array();
for ($num=21;$num<41;$num++){
   $check[$num] = $fieldrow['check' . $num];
if ($check[$num] !== null){
echo "<td align=center>$check[$num] <input type='checkbox' name='check[$num]' value='yes'/></td>";
}
if ($i == 4){
echo "</tr> <tr align=center>";
$i=0;
}
$i++;
}
//------------==========---------------========----------------------------------===================
echo "</table></td></tr><tr align=center><td align=center>
<input class='form-input-button'
                type='reset'
                name='Reset'
                value='Reset' /> 
          <input class='form-input-button'
                type='submit'
                name='Submit'
                value='Submit' />
</td></tr></table></form>";
?>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.