loquela Posted August 15, 2009 Share Posted August 15, 2009 OK, this is doing my nut in. I just can't see the login. PLEASE help!! $query = 'INSERT INTO results (result_response) VALUES (' .implode('), (', $_POST['response']) . ')'; Now, this works just fine, but I want to add some more columns to the INSERT, say $this_value and $that_value). What ever I try returns a column mismatch error, parse error or unknown column error. HELP!! :'( Quote Link to comment Share on other sites More sharing options...
waynewex Posted August 15, 2009 Share Posted August 15, 2009 Your query is all wrong. You've single quotes littered everywhere. What are you trying to do exactly? Quote Link to comment Share on other sites More sharing options...
loquela Posted August 15, 2009 Author Share Posted August 15, 2009 There's nothng wrong with the query as it stands other than I just don't get how it works. But it DOES work. It's inserting the content of an array into multiples records - the array values are going into the result_response column of the table. However, what I want to do but can't work out how, is add is populate the other columns in each row. Quote Link to comment Share on other sites More sharing options...
smerny Posted August 15, 2009 Share Posted August 15, 2009 $query = 'INSERT INTO results (result_response, other_field) VALUES (' .implode('), (', $_POST['response']) . ', $othervalue)'; Quote Link to comment Share on other sites More sharing options...
loquela Posted August 15, 2009 Author Share Posted August 15, 2009 That's what I thought smerny. But I just get: Column count doesn't match value count at row 1 :'( Quote Link to comment Share on other sites More sharing options...
smerny Posted August 15, 2009 Share Posted August 15, 2009 Well try to keep queries as simple as possible... $response = implode('), (', $_POST['response']) $query = "INSERT INTO results (result_response, other_field) VALUES ('$response', '$othervalue')"; Quote Link to comment Share on other sites More sharing options...
loquela Posted August 15, 2009 Author Share Posted August 15, 2009 Thanks smerny, OK, now we are getting somewhere (sort of). This works insofar as it inserts the addition field. But now it only inserts one row. There are 6 elements to the array and before in inserted all 6 rows. :-\ Quote Link to comment Share on other sites More sharing options...
loquela Posted August 15, 2009 Author Share Posted August 15, 2009 This works fine, inserts all 6 records, but is only inserting a value into one field: $query = 'INSERT INTO fb_response (response_response) VALUES (' .implode('), (', $_POST['response']) . ')'; This successfully populates the additional field, but inserts only one row: $response = implode('), (', $_POST['response']); $query = "INSERT INTO results (result_response, other_field) VALUES ('$response', '$othervalue')"; Anyone able to figure out what's happening? My head is getting really sore on that wall :'( 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.