"John Holmes" <[EMAIL PROTECTED]> wrote in message
001201c21ab5$0df073a0$b402a8c0@mango">news:001201c21ab5$0df073a0$b402a8c0@mango...
> Your second method should work, but it's dependent on what your form
> looks like and how your table was created. You obviously have a key set
> for this column and you're trying to insert the same value twice, which
> makes an error.
>
> Show us what your form looks like, not the whole thing, just for the
> checkboxes. Also, what does your CREATE TABLE look like for the table
> your trying to insert this data into?
>
> ---John Holmes...
>
> > -----Original Message-----
> > From: Rob Packer [mailto:[EMAIL PROTECTED]]
> > Sent: Sunday, June 23, 2002 7:50 AM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP] Insert an array into MySQL
> >
> > Hi, I've seen a few post for this same thing but I can't seem to get
> it
> > working. What I'm doing is taking a form with check boxes and putting
> them
> > into an array. Then I'm attempting to INSERT them into the db, one
> > checkbox
> > value per row.
> >
> > Okay,  well I've tries 2 ways that I think should work and they only
> > insert
> > the first value. They both produce this error "Duplicate entry '0' for
> key
> > 1" (which I don't understand) Anyway here is the code I'm trying...
> >
> > (I'm not trying to use both blocks of code, just one or the other)
> >
> > // First code
> > while(list($key,$value)=each($pagetype)){
> > //echo $value."<br>";//test
> > $links="INSERT INTO $username_links (links) VALUES ('$value')";
> > $insert=mysql_query($links,$connection);
> >
> > }
> >
> > // Second code attempt
> > $number=count($pagetype);
> > for($a=0;$a<$number;$a++){
> > $links="INSERT INTO $username_links (links) VALUES ('$pagetype[$a]')";
> > $insert=mysql_query($links) or die(mysql_error());
> > //echo $pagetype[$a];//test
> > }
> >
> >
> >
> >
> > Thanks in advance...Robert
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to