Jump to content

Getting error when trying to insert data from form


jim.davidson

Recommended Posts

I get this error when trying to insert form data and don't know why

 

Unknown column 'yes' in 'field list'

 

The table has (4) columns committee_member_id, committee_id, member_id, and chairman

 

Here's the code

 

$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
  if (empty($_POST['committee_id'])) {
    $error['committee'] = 'You must select a committee';
  }
  else {
   $committee_id = $_POST['committee_id'];
  }
  if (empty($_POST['member_id'])) {
    $error['member'] = 'You must select a member';
  }
  else {
   $member_id = $_POST['member_id'];
  }
 
  if (isset($_POST['chairman_group'])) {
    $chairman = $_POST['chairman_group'];  
  } 


 if (!$error) {
   // Assign the tag
    $insertSQL = sprintf("INSERT INTO committee_members (committee_id, member_id, chairman) VALUES (%s, %s, %s)",
     GetSQLValueString($committee_id, "int"),
      GetSQLValueString($member_id, "int"),
      GetSQLValueString($chairman, "txt"));
        mysql_select_db($database_racc, $racc);
        $Result1 = mysql_query($insertSQL, $racc) or die(mysql_error());
  }
}

 

Any help will be greatly appreciated.

 

Change the error handling a bit so you can see the actual statement:

 

 

$Result1 = mysql_query($insertSQL, $racc) or die("Error: " . mysql_error() . "<br>Query: " . $insertSQL);

 

and display the results of the above.

 

Also, if you are expecting committee_id and member_id to contain integers, %d instead of %s should be passed to printf()

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.