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. Link to comment https://forums.phpfreaks.com/topic/108468-solved-syntax-issue-concat/ 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()); Link to comment https://forums.phpfreaks.com/topic/108468-solved-syntax-issue-concat/#findComment-556466 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 Link to comment https://forums.phpfreaks.com/topic/108468-solved-syntax-issue-concat/#findComment-556472 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.