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

Link to comment
Share on other sites

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

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.