Hi,

I was missing two single quotes in the $val line after $id[$i] and before
songname :  Here is the corrected code

 $vals .=", ('$id[$i]', '$songname[$i]', '$rating[$i]', '$video[$i]',
'$album_id[$i]',
    '$movie[$i]')";

Now the problem is it only inserts one row into the table, when there should be
more than one row inserted.

Here is the updated code:

<?
if (isset($songname)&& isset($rating)){
   mysql_connect("24.1.15.33", "webuser", "");
  echo $id[0];

$vals='';
for ($i=0; $i<= $songsinalbum; $i++) {
  $vals .=", ('$id[$i]', '$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;

$result = mysql_db_query("movies", $qry);
// $res=mysql_query("movies", $qry);
$error_number = mysql_errno();
$error_msg = mysql_error();
echo "MySQL error $error_number: $error_msg";

Here is part of the form:
<TD align="right">Songname:  </TD><TD><input type=text name=songname[]
size=30><br></TD>

Dvořáček Michal wrote:

> Hi,
>
> if you have 6 colums, you are inserting only 5 in table
>
> INSERT INTO songs VALUES (' 1, blah', ' ***', ' 45', ' 2', ' ')
>                          [1th       ] [2nd]   [3rd]  [4th] [5th]
>
> i think that first apostrophe is shifted to left side
> should be:
> INSERT INTO songs VALUES (1, 'blah', ' ***', 45, 2, ' ');
>
> hint: numeric fields don't required to be in apostrophes
>
>    Michal Dvoracek                           [EMAIL PROTECTED]
>
>    database, table, query
>
> ---------------------------------------------------------------------
> 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