Jump to content

[SOLVED] Syntax issue? Concat


mickinell

Recommended Posts

$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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.