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.

 

Link to comment
Share on other sites

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()

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.