gopichand Posted September 6, 2006 Share Posted September 6, 2006 am using a list box in the front end and the user selects more than one option from the list box..all these options must go into a single column in a table of the datbase..only one value is getting inserted into the column with the query here and moreover it is generating an error ..How to insert all the selected values into a single dabatase column,I hope u understood this?$query = "INSERT INTO tutorials (uid, name, dname, cname, date, description, Keywords, SLO) VALUES ('" . $user . "','" . $name . "','" . $dname . "','" . $cname . "','" . $date \. "','" . $description . "','" . $_POST['Keywords'] . "','" . join("'), ('", $_POST['name_here']) . "')";This query is generating the following errorINSERT INTO tutorials (uid, name, dname, cname, date, description, Keywords, SLO) VALUES ('22','akkf','kajfkafka','kasjfk','1157560060','kdfakf','fjakfaj','9'), ('8'), ('7')Column count doesn't match value count at row 2How to solve this problem? Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted September 6, 2006 Share Posted September 6, 2006 Here you are specifying which columns you are inserting values for, 8 of them.INSERT INTO tutorials (uid, name, dname, cname, date, description, Keywords, SLO) Here is your first set of values, 8 of them('22','akkf','kajfkafka','kasjfk','1157560060','kdfakf','fjakfaj','9'),Here is your second set of values, 1 value('8'), If you tell MySQL you are inserting into 8 columns, you have to insert 8 values for every row. Quote Link to comment Share on other sites More sharing options...
drranch Posted September 6, 2006 Share Posted September 6, 2006 Should that comma be in the front of $POST ('"[color=red],[/color] $_POST['name_here']) . 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.