Jump to content

INSERT arrays and strings !!!


loquela

Recommended Posts

OK, this is doing my nut in. I just can't see the login. PLEASE help!!  :facewall:

 

$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!! :facewall::shrug: :'(

Link to comment
https://forums.phpfreaks.com/topic/170411-insert-arrays-and-strings/
Share on other sites

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.

:facewall:

 

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  :facewall:  :'(

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.