Re: INSERT Array Values into mySQL Table
| From: | Rahul Sitaram Johari | Date: | Wed, 02 May 2007 16:10:17 +0000 |
| Subject: | Re: INSERT Array Values into mySQL Table | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-254243@lists.php.net to get a copy of this message | ||
Ave,
I was just about to post when I saw your message. I think what you're saying
is exactly what is happening. The values have Spaces and stuff so Quotes are
Required - cannot have values not enclosed in Quotes. Other then that it was
actually working.
Is there a way to enclose in Quotes using the implode statement?
On 5/2/07 12:03 PM, "Jim Moseby" <JMoseby@nrbindustries.com> wrote:
>>
>> $sql = "INSERT INTO table (f1, f2, f3, ". implode(",",
>> array_keys($pr1)) .")
>> VALUES ('abc', '123', '456', ". implode(",",
>> array_values($pr1))
>> .")";
>>
>> HTH,
>>
>> Brad
>
>
> Might not work if the array values need to be enclosed in quotes. I would
> build the query string in a foreach loop and execute the query afterwards.
>
> JM