Forum Moderators: coopster

Message Too Old, No Replies

Plz Help: Column count doesn't match value count at row 1

         

gspabla

8:00 pm on Apr 15, 2009 (gmt 0)

10+ Year Member



Error: Could not insert data because Column count doesn't match value count at row 1

I have add new field 'Mobilee' after that when im trying to submit the form i got this error
please help

my code is


// insert the data
$insert = mysql_query("insert into register (Termsofservice,ConfirmEmail,ConfirmPassword,Profilecreatedby,Referenceby, Name,Gender,DOB,Age,TOB,POB,Maritalstatus,childrenlivingstatus,Education, EducationDetails,Occupation,Employedin,Annualincome,Religion,Caste,Subcaste, Subcastee,Gothram,Language,Star,Moonsign,Horosmatch,Manglik,Height,Weight, BloodGroup,Bodytype,Complexion,Diet,Smoke,Drink,Address,City,State,Country, Phone,Mobile,Mobilee,Residencystatus,Fathername,Mothersname,Fatherlivingstatus, Motherlivingstatus,Fathersoccupation,Mothersoccupation,Profile,Looking, FamilyDetails,Familyvalues,FamilyType,FamilyStatus,FamilyOrigin,noofbrothers, noofsisters,nbm,nsm,PE_FromAge,PE_ToAge,PE_HaveChildren,PE_Height, PE_Complexion,PE_MotherTongue,PartnerExpectations,PE_Religion,PE_Caste, PE_Education,PE_Countrylivingin,PE_Residentstatus,Hobbies,OtherHobbies, Interests,OtherInterests,Status,Regdate,IP,Ref,Agent,Orderstatus, photochecklist,videochecklist,Horoschecklist) values ('".$_SESSION['Accept']."', '".$_SESSION['ConfirmEmail']."', '".$_SESSION['ConfirmPassword']."', '".$_SESSION['ProfileCreatedby']."', '".$_SESSION['Referenceby']."', '".$_SESSION['Name']."', '".$_SESSION['Gender']."', '".$_SESSION['DateofBirth']."', '".$_SESSION['Age']."', '".$_SESSION['Timeofbirth']."', '".$_SESSION['Placeofbirth']."', '".$_SESSION['MaritalStatus']."', '".$_SESSION['ChildrenLivingStatus']."', '".$_SESSION['Education']."', '".$_SESSION['EduDetails']."', '".$_SESSION['eduDetail']."', '".$_SESSION['Occupation']."', '".$_SESSION['Employedin']."', '".$_SESSION['Annualincome']."', '".$_SESSION['Religion']."', '".$_SESSION['Caste']."', '".$_SESSION['SubCaste']."', '".$_SESSION['SubCastee']."', '".$_SESSION['Gothra']."', '".$_SESSION['Mothertongue']."', '".$_SESSION['Star']."', '".$_SESSION['Moonsign']."', '".$_SESSION['HoroscopeMatch']."', '".$_SESSION['Manglik']."', '".$_SESSION['Height']."', '".$_SESSION['Weight']."', '".$_SESSION['BloodGroup']."', '".$_SESSION['Bodytype']."', '".$_SESSION['Complexion']."', '".$_SESSION['Diet']."', '".$_SESSION['Smoke']."', '".$_SESSION['Drink']."', '".$_SESSION['Address']."', '".$_SESSION['City']."', '".$_SESSION['State']."', '".$_SESSION['Country']."', '".$_SESSION['Phone']."', '".$_SESSION['Mobile']."','".$_SESSION['Mobilee']."', '".$_SESSION['Residencein']."','".$_POST['txtFANAME']."', '".$_POST['txtMONAME']."', '".$_POST['txtFalive']."', '".$_POST['txtMalive']."', '".$_POST['txtFFO']."', '".$_POST['txtFMO']."','".$_POST['txtmsg']."', '".$_POST['txtLooking']."', '".$_POST['txtFD']."','".$_POST['txtFV']."','".$_POST['txtFT']."', '".$_POST['txtFS']."', '".$_POST['txtFO']."','$fs1','$fs2','$nbm','$nsm','".$_POST['Fromage']."', '".$_POST['Toage']."', 'NULL', '".$_POST['txtPHeight']."', '".$_POST['txtPComplexion']."','NULL','".$_POST['txtPPE']."', '".$_POST['religion']."', '".$_POST['caste']."','".$_POST['txtPEdu']."', '".$_POST['txtPcountry']."', '".$_POST['txtPReS']."', '".$_POST['txtHobby']."', '".$_POST['txtOh']."','".$_POST['txtInterest']."','".$_POST['txtOi']."', '".$_POST['txtstatus']."','".$_POST['txtregdate']."','".$_POST['txtip']."', '".$_POST['txtref']."','".$_POST['txtagent']."','$strorderstatus', '$strchkcross','$strchkcross','$strchkcross')")

or die("Could not insert data because ".mysql_error());
$uid=mysql_insert_id();

[edited by: dreamcatcher at 8:42 pm (utc) on April 15, 2009]
[edit reason] Fixed Side Scroll [/edit]

rocknbil

10:35 pm on Apr 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard gspabla - your error means just what it means. Carefully count the columns

insert into table (columns)

and the values

values(values)

and you're either missing some or have too many in one or the other.

This might be easier to manage as a loop.

foreach ($input_values as $columnName=>$value) {
$fields .= "$columnName,";
$values .= "'$value',";
}
// kill last comma, many ways to do it
$fields = $preg_replace("/,$/",'',$fields);
$values = $preg_replace("/,$/",'',$values);

$select = "insert into table ($fields) values ($values)";