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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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