Thanks for the help

I tried your code and received error.

Warning: No ending delimiter '^' found in addsongs.php on line 26
Songname: Array
INSERT Failed, check the code.........

The code was: $vals=preg_replace('^,', '', $vals); // chop leading comma

Is the ^ an escape character so you can enter a comma within ' '   ?
I couldn't find reference to ^ as an escape character in php docs.
http://www.php.net/manual/en/function.preg-replace.php

I also tried '/,'
Warning: Unknown modifier ',' in /var/www/html/databases/music/addsongs.php on
line 26
Songname: Array
.

Any ideas?



Don Read wrote:

> On 14-Jul-01 David wrote:
> > I need to insert x amount of rows from one form.  The form displays x
> > amount of rows.  I then need to insert the values from the form x amount
> > of times.  The form loop works fine but how do I INSERT x amount of
> > times within a loop from the values of the form?  I think I need to use
> > some sort of array. I suck at arrays.
> >
> > This executes when submit is hit:
> > $i = 1;
> > while ($i <= $songsinalbum) {
> >  $query = "INSERT INTO songs VALUES ('$id',
> > '$songname','$rating','$video', '$album_id', '$movie')";
> >    $result = mysql_db_query("movies", $query);
> > };
> >
> >
>
> $vals='';
> for ($i=0; $i<= $songsinalbum; $i++) {
>   $vals .=", ('$songname[$i]', '$rating[$i]', '$video[$i]', '$album_id[$i]',
>     '$movie[$i]')";
> }
>
> $vals=preg_replace('^,', '', $vals); // chop leading comma
>
> $qry="INSERT INTO songs VALUES $vals";
>
> // echo $qry, '<br>;
>
> $res=mysql_query($qry);
>
>  ...
>
> >
> > Here is form:
>
> <TD align="right">Songname:  </TD><TD><input type=text name='songname[]'
> size=30><br></TD>
>  <TD align="right">Rating:   </TD><TD><input type=text name='rating[]'
>
> etc.
>
> Regards,
> --
> Don Read                                       [EMAIL PROTECTED]
> -- It's always darkest before the dawn. So if you are going to
>    steal the neighbor's newspaper, that's the time to do it.
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to