View Full Version : Query Error Help

07-30-2007, 07:32 PM

I'm trying to run a query and I'm receiving the following message:
Column count doesn't match value count at row 1.

I printed my table structure and cross-referenced to my insert statement and everything seems to be in order. I also printed a detail error message showing me the data for each field. I cross-referenced the data with the table and everything seems correct. I don't know what I'm missing.

Can someone help me out?

This is my query statement:

$query4 = "REPLACE INTO initial_plan (client_id, caseno, legal_status, emergency_no, ed_voc_status, ed_voc_stat_other, special_services, strength_assessment, reason_for_admin,
meds1, meds2, meds3, meds4, meds5, dosage1, dosage2, dosage3, dosage4, dosage5, last_dental, medical_history, current_med_needs,
special_behavior_concerns1, special_behavior_concerns2, special_behavior_concerns3, special_behavior_concerns4, special_behavior_concerns5,
isp_deadline, treatment_need1, treatment_goal1, treatment_need2, treatment_goal2, treatment_need3, treatment_goal3, treatment_need4, treatment_goal4, treatment_need5, treatment_goal5, treatment_need6, treatment_goal6,
recommend_assessment, fund_agency, level_of_care, fund_rate)

VALUES ('$_POST[client_id]', '$_POST[caseno]', '$_POST[legal_status]', '$_POST[emergency_no]', '$_POST[ed_voc_status]', '$_POST[ed_voc_stat_other]',
'$_POST[special_services]', '$_POST[strength_assessment]', '$_POST[reason_for_admin]', '$_POST[meds1]', '$_POST[meds2]', '$_POST[meds3]', '$_POST[meds4]',
'$_POST[meds5]', '$_POST[dosage1]', '$_POST[dosage2]', '$_POST[dosage3]', '$_POST[dosage4]',
'$_POST[dosage5]', '$_POST[last_dental]', '$_POST[medical_history]', '$_POST[current_med_needs]', '$_POST[special_behavior_concerns1]', '$_POST[special_behavior_concerns2]',
'$_POST[special_behavior_concerns3]', '$_POST[special_behavior_concerns4]', '$_POST[special_behavior_concerns5]', '$_POST[isp_deadline]', '$_POST[treatment_need1]',
'$_POST[treatment_goal1]', '$_POST[treatment_need2]', '$_POST[treatment_goal2]', '$_POST[treatment_need3]'
'$_POST[treatment_goal3]', '$_POST[treatment_need4]', '$_POST[treatment_goal4]', '$_POST[treatment_need5]', '$_POST[treatment_goal5]', '$_POST[treatment_need6]', '$_POST[treatment_goal6]', '$_POST[recommend_assessment]',
'$_POST[fund_agency]', '$_POST[level_of_care]', '$_POST[fund_rate]')";

Thanks for the help.

07-30-2007, 07:56 PM
Unless there is some other mis-match, you are missing a coma at the end of the following value -

'$_POST[treatment_need3]' <----- , missing here

07-31-2007, 02:41 AM

Thank you so much. I thought it was going to be something as simple as a missing comma. The comma was definately the problem.

Is there a text editor for PHP which highlights the errors?

Thanks again for the help.

07-31-2007, 03:07 AM
Highlighting editors are available, but this is limited to quoted strings, and matching up language elements, {}, if/else and such. For finding something like a missing coma from a list of data requires old fashion proof reading. I went thought the list, putting each item on its own line (I was going to see if there were in fact a matching number of columns called out and values listed.) When I got to a line that did not have the coma after the data, I knew I had found a problem.

07-31-2007, 04:03 AM
Thanks for the info.