mickinell Posted June 3, 2008 Share Posted June 3, 2008 $sql = "INSERT INTO lesson_plan VALUES ('', '".$date."', '".addslashes($topic)."', '".addslashes($essques)."', '".addslashes($summary)."', '".addslashes($procedure)."', '".addslashes($resources)."', '".addslashes($notes)."', 'CONCAT_WS (',', ".($strat ? implode("," , $strat) : "").", ".($eval ? implode("," , $eval) : "").", ".($sta ? implode("," , $sta) : "").")')"; $result = @mysql_query($sql,$connection) or die(mysql_error()); What's wrong here? I have a table with 9 fields. When I try this query, I get "Column count doesn't match value count at row 1." ??? I know it has something to do with my last part (I replaced the concat part with '1' as a test) but I can't figure it out. Quote Link to comment Share on other sites More sharing options...
mickinell Posted June 3, 2008 Author Share Posted June 3, 2008 I figured it out myself. The correct way, in case there's someone else trying to figure this out like I was: $sql = "INSERT INTO lesson_plan VALUES ( '', '".$date."', '".addslashes($topic)."', '".addslashes($essques)."', '".addslashes($summary)."', '".addslashes($procedure)."', '".addslashes($resources)."', '".addslashes($notes)."', '".($strat ? implode("," , $strat) : "").",".($eval ? implode("," , $eval) : "").",".($sta ? implode("," , $sta) : "")."' )"; $result = @mysql_query($sql,$connection) or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
luca200 Posted June 3, 2008 Share Posted June 3, 2008 The correct way to avoid some headache would be not to mess your code with that horrible mix of single and double quotes, and set variables before you use them in the query... imho of course Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.