Hello.
I'm new to php and sql.
I nee to insert data in multiple tables and rows. the problem, in the first table, I just nedd 1 row, and that's fine, in the scond i need to input data in the minimum of 1 row and max of 6 row's. in the second table, no data is inserted, can you help me?? Thanks in advance.

php code ( entrada.php)

<?php


 //conecção ao servidor
$conn = mysql_connect("localhost", "root")or die("sem conecção ao servidor"); 
$db = mysql_select_db("sermail")or die("Base de dados não foi encontrada");
 // VAriaveis  
   //ordem 

    $data = date("dmY");
    $nordem = $_POST['nordem'];
    $guian = $_POST['guian'];
    $ncliente = $_POST['ncliente'];
    $cliente = $_POST['cliente'];
    $fornecedor = $_POST['fornecedor'];       
         // entrada linha1
     $check = $_POST['check'][$i];
    $lote = $_POST['lote'][$i];
    $val = $_POST['val'][$i];
    $designacao = $_POST['designacao'][$i];
    $filtro = $_POST['filtro'][$i];
    $familiamarca = $_POST['familiamarca'][$i];
    $quantguia = $_POST['quantguia'][$i];
    $quantconf = $_POST['quantconf'][$i];
    $atado = $_POST['atado'][$i];
    $posicao = $_POST['posicao'][$i];
    $codprod = $_POST['codprod'][$i];

echo $sql="INSERT INTO ordem(data, nordem, fornecedor, guian, ncliente, cliente)
VALUES( '".$data."', '".$nordem."', '".$fornecedor."', '".$guian."', '".$ncliente."', '".$cliente."')";
echo "</br>";
mysql_query ($sql);
$exec=mysql_query($sql);        

echo $sql = 'INSERT INTO \'entrada\' (\'nordem_n\', \'lote\', \'val\', \'designacao\', \'familiamarca\', \'quantguia\', \'quantconf\', \'atado\', \'posicao\', \'codprod\') VALUES';

for ($i=0; $i<count($_POST['lote']); $i++) {
    $sql .= '(\'' . $_POST['lote'][$i] . '\', \'' . $_POST['val'][$i] . '\', \'' . $_POST['designacao'][$i] . '\', \'' . $_POST['familiamarca'][$i] . '\', \'' . $_POST['quantguia'][$i] . '\', \'' . $_POST['quantconf'][$i] . '\', \'' . $_POST['atado'][$i] . '\', \'' . $_POST['posicao'][$i] . '\', \'' . $_POST['codprod'][$i] . '\')';
    if ($i<count($_POST['lote']) - 1) {
       $sql .= ',';
    }
}







  ?> 
<?php 
mysql_close();
 ?>

html code ( form.html)

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
    <head>

        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Ficha de entrada de material</title>
        <meta name="alex" content="sermail" />
        <link rel="stylesheet" type="text/css" href="styles/styles.css" />
        <script type="text/javascript">
 function printpage()
   {
   window.print()
   }
 </script>
    <script>
      function showMe (it, box) {
       var vis = (box.checked) ? "block" : "none";
      document.getElementById(it).style.display = vis;
      }
     </script>

<style type="text/css" media="print">
   .printbutton {
   visibility: hidden;
   display: none;
   }
   .validado {
   visibility: hidden;
   display: none;
   }
    .background{ color: #0000;}
    .page landscape {size: landscape;}
    .page
    { bgcolor: #0000; }
    .h1{color: #000;
    font-family: Times New Roman, sans-serif;
    font-size: 18px;
    font-weight: bold;
    text-align: left;}
    .h2{color: #000;
    font-weight: normal;
    text-align: center;
    font-family: Times New Roman, sans-serif;
    font-size: 16px;}

</style>


    </head>
    <body bgcolor= #00814B>
    <div class="body">
        <div class="content">
        <br><br><br><br><br>
<form action="entrada.php" method="post">
 <table width="1000px"> <tr><td width="600px"><h1>

 N.º Ordem: <input type="text" size="6" name="nordem" />
 Fornecedor: <input type="text" size="10" name="fornecedor"/><br>
 Guia n.º: <input type="text" size="6" name="guian"/>
 N.º Cliente: <input type="text" size="8"name="ncliente" />
 Cliente: <input type="text" size="15"name="cliente"  /></h1></td><td width="250px"</td><td><img src="imas/sermaillogo.png"></td></tr>





 <table border="1" id="produtos" width="900px"  >
 <tr ><td></td>
 <td width="80px"><h2>Cód. <br/>Produto </h2></td>
 <td width="80px"><h2>Cód. Cliente 1<br>Lote</h2></td>
 <td width="80px"><h2>Cód. Cliente 2<br>validade</h2></td>
 <td width="80px"><h2>Designação</h2></td>
 <td width="80px"><h2>Filtro 1 <br> Unidade de negócio</h2></td>
 <td width="80px"><h2>Familia/Marca</h2></td>
 <td width="80px"><h2>Quant. Guia</h2></td>
 <td width="80px"><h2>Quant. Conferida</h2></td>
 <td width="80px"><h2>Atado</h2></td>
 <td width="80px"><h2>Posição</h2></td>
   </tr>


<tr><td><input type="hidden" name="check[]"  value="0"  /><input type="checkbox" name="check[]"  value="1"  /></td>
 <td width="80px"><input type="text" size="8"name="codprod[]" /></td>
 <td width="80px"><input type="text" size="8"name="lote[]" /></td>
 <td width="80px"><input type="text" size="10"name="val[]" /></td>
 <td width="80px"><input type="text" size="30"name="designacao[]"  /></td>
 <td width="80px"><input type="text" size="10"name="filtro[]"  /></td>
 <td width="80px"><input type="text" size="15"name="familiamarca[]"/></td>
 <td width="80px"><input type="text" size="6"name="quantguia[]" /></td>
 <td width="80px"><input type="text" size="6"name="quantconf[]"  /></td>
 <td width="80px"><input type="text" size="6"name="atado[]"  /></td>
 <td width="80px"><input type="text" size="6"name="posicao[]" /></td>
 </tr>

<tr><td><input type="hidden" name="check[]"  value="0"  /><input type="checkbox" name="check[]"  value="1"  /></td>
 <td width="80px"><input type="text" size="8"name="codprod[]" /></td>
 <td width="80px"><input type="text" size="8"name="lote[]" /></td>
 <td width="80px"><input type="text" size="10"name="val[]" /></td>
 <td width="80px"><input type="text" size="30"name="designacao[]"  /></td>
 <td width="80px"><input type="text" size="10"name="filtro[]"  /></td>
 <td width="80px"><input type="text" size="15"name="familiamarca[]"/></td>
 <td width="80px"><input type="text" size="6"name="quantguia[]" /></td>
 <td width="80px"><input type="text" size="6"name="quantconf[]"  /></td>
 <td width="80px"><input type="text" size="6"name="atado[]"  /></td>
 <td width="80px"><input type="text" size="6"name="posicao[]" /></td>
 </tr>
<tr><td><input type="hidden" name="check[]"  value="0"  /><input type="checkbox" name="check[]"  value="1"  /></td>
 <td width="80px"><input type="text" size="8"name="codprod[]" /></td>
 <td width="80px"><input type="text" size="8"name="lote[]" /></td>
 <td width="80px"><input type="text" size="10"name="val[]" /></td>
 <td width="80px"><input type="text" size="30"name="designacao[]"  /></td>
 <td width="80px"><input type="text" size="10"name="filtro[]"  /></td>
 <td width="80px"><input type="text" size="15"name="familiamarca[]"/></td>
 <td width="80px"><input type="text" size="6"name="quantguia[]" /></td>
 <td width="80px"><input type="text" size="6"name="quantconf[]"  /></td>
 <td width="80px"><input type="text" size="6"name="atado[]"  /></td>
 <td width="80px"><input type="text" size="6"name="posicao[]" /></td>
 </tr>
<tr><td><input type="hidden" name="check[]"  value="0"  /><input type="checkbox" name="check[]"  value="1"  /></td>
 <td width="80px"><input type="text" size="8"name="codprod[]" /></td>
 <td width="80px"><input type="text" size="8"name="lote[]" /></td>
 <td width="80px"><input type="text" size="10"name="val[]" /></td>
 <td width="80px"><input type="text" size="30"name="designacao[]"  /></td>
 <td width="80px"><input type="text" size="10"name="filtro[]"  /></td>
 <td width="80px"><input type="text" size="15"name="familiamarca[]"/></td>
 <td width="80px"><input type="text" size="6"name="quantguia[]" /></td>
 <td width="80px"><input type="text" size="6"name="quantconf[]"  /></td>
 <td width="80px"><input type="text" size="6"name="atado[]"  /></td>
 <td width="80px"><input type="text" size="6"name="posicao[]" /></td>
 </tr>
<tr><td><input type="hidden" name="check[]"  value="0"  /><input type="checkbox" name="check[]"  value="1"  /></td>
 <td width="80px"><input type="text" size="8"name="codprod[]" /></td>
 <td width="80px"><input type="text" size="8"name="lote[]" /></td>
 <td width="80px"><input type="text" size="10"name="val[]" /></td>
 <td width="80px"><input type="text" size="30"name="designacao[]"  /></td>
 <td width="80px"><input type="text" size="10"name="filtro[]"  /></td>
 <td width="80px"><input type="text" size="15"name="familiamarca[]"/></td>
 <td width="80px"><input type="text" size="6"name="quantguia[]" /></td>
 <td width="80px"><input type="text" size="6"name="quantconf[]"  /></td>
 <td width="80px"><input type="text" size="6"name="atado[]"  /></td>
 <td width="80px"><input type="text" size="6"name="posicao[]" /></td>
 </tr>
<tr><td><input type="checkbox" name="check[]"  value="1"  /></td>
 <td width="80px"><input type="text" size="8"name="codprod[]" /></td>
 <td width="80px"><input type="text" size="8"name="lote[]" /></td>
 <td width="80px"><input type="text" size="10"name="val[]" /></td>
 <td width="80px"><input type="text" size="30"name="designacao[]"  /></td>
 <td width="80px"><input type="text" size="10"name="filtro[]"  /></td>
 <td width="80px"><input type="text" size="15"name="familiamarca[]"/></td>
 <td width="80px"><input type="text" size="6"name="quantguia[]" /></td>
 <td width="80px"><input type="text" size="6"name="quantconf[]"  /></td>
 <td width="80px"><input type="text" size="6"name="atado[]"  /></td>
 <td width="80px"><input type="text" size="6"name="posicao[]" /></td>
 </tr>

 </table>

 <input type="submit"/ class="printbutton" value="Inserir entrada"><br/>
 <input type="button"class= "validado" value="Imprimir" onclick="printpage()" />

<INPUT type="button" value="Fechar" onClick="window.close()">
</form>



</div>
</div>
    </body>
</html>

Recommended Answers

All 71 Replies

If that is all code, the second query is never executed.

why? pleaze help me undersant what am I doing wrong!
what's the solution?

ok same var for 2 difernt query's, one mistake, corrected it, but still don't add any row to the table... HELP PLEASE

Show your corrected PHP code.

  <?php
    //conecção ao servidor
    $conn = mysql_connect("localhost", "root")or die("sem conecção ao servidor");
    $db = mysql_select_db("sermail")or die("Base de dados não foi encontrada");
    // VAr
    //table ordem
    $data = date("dmY");
    $nordem = $_POST['nordem'];
    $guian = $_POST['guian'];
    $ncliente = $_POST['ncliente'];
    $cliente = $_POST['cliente'];
    $fornecedor = $_POST['fornecedor'];
    // table entrada 
    $check = $_POST['check'][$i];
    $lote = $_POST['lote'][$i];
    $val = $_POST['val'][$i];
    $designacao = $_POST['designacao'][$i];
    $filtro = $_POST['filtro'][$i];
    $familiamarca = $_POST['familiamarca'][$i];
    $quantguia = $_POST['quantguia'][$i];
    $quantconf = $_POST['quantconf'][$i];
    $atado = $_POST['atado'][$i];
    $posicao = $_POST['posicao'][$i];
    $codprod = $_POST['codprod'][$i];

    //insert data table ordem
    echo $sql="INSERT INTO ordem(data, nordem, fornecedor, guian, ncliente, cliente)
    VALUES( '".$data."', '".$nordem."', '".$fornecedor."', '".$guian."', '".$ncliente."', '".$cliente."')";
    echo "</br>";
    mysql_query ($sql);
    $exec=mysql_query($sql);

    //insert data table entrada
    echo $sql2 = 'INSERT INTO \'entrada\' (\'nordem_n\', \'lote\', \'val\', \'designacao\', \'familiamarca\', \'quantguia\', \'quantconf\', \'atado\', \'posicao\', \'codprod\') VALUES';
    for ($i=0; $i<count($_POST['check']); $i++) {
    $sql2a= '(\'' . $_POST['lote'][$i] . '\', \'' . $_POST['val'][$i] . '\', \'' . $_POST['designacao'][$i] . '\', \'' . $_POST['familiamarca'][$i] . '\', \'' . $_POST['quantguia'][$i] . '\', \'' . $_POST['quantconf'][$i] . '\', \'' . $_POST['atado'][$i] . '\', \'' . $_POST['posicao'][$i] . '\', \'' . $_POST['codprod'][$i] . '\')';
    if ($i<count($_POST['check']) - 1) {
    $sql2a= ',';
    }
    }
    ?>
    <?php
    mysql_close();
    ?>
  1. Remove line 31, it does the same as 30.
  2. Line 34: Change $sql2 to $sql2a
  3. Line 36: Change = to .=
  4. Line 38: Change = to .=
  5. Before line 43, add mysql_query ($sql2a);
$sql2 = array(); 
foreach( $data as $row ) {
    $sql[] = '("'.mysql_real_escape_string($row['text']).'", '.$row['category_id'].')';
}
mysql_query('INSERT INTO table (text, category) VALUES '.implode(',', $sql));

this query, echoes the values correctly but does not insert them in the table, i don't understand why.

I'm trying to put it to work for days's, i need help. thanks

Now you are using double quotes around your text. MySQL needs single quotes.

Always use this when developing:

mysql_query(...) or die(mysql_error());

So you can see if there are errors in your sql.

sorry, the last code i've pasted isn't mine.. the code i wanted to past was:

> //insert data table entrada
> echo $sql2 = 'INSERT INTO \'entrada\' (\'nordem_n\', \'lote\', \'val\', \'designacao\', \'familiamarca\', \'quantguia\', \'quantconf\', \'atado\', \'posicao\', \'codprod\') VALUES';
> for ($i=0; $i<count($_POST['check']); $i++) {
> $sql2a= '(\'' . $_POST['lote'][$i] . '\', \'' . $_POST['val'][$i] . '\', \'' . $_POST['designacao'][$i] . '\', \'' . $_POST['familiamarca'][$i] . '\', \'' . $_POST['quantguia'][$i] . '\', \'' . $_POST['quantconf'][$i] . '\', \'' . $_POST['atado'][$i] . '\', \'' . $_POST['posicao'][$i] . '\', \'' . $_POST['codprod'][$i] . '\')';
> if ($i<count($_POST['check']) - 1) {
> $sql2a= ',';
> }
> }

My previous points still apply.

doble quotes? where? help me please, i can't see them.
and is this the best way to make it?

No. My reply with the 5 points...

ok, done that 5 points, still the same. mysql guives me notices in all variables, and the echoes of the query's are:

INSERT INTO ordem(data, nordem, fornecedor, guian, ncliente, cliente) VALUES( '31072012', '12', '23', '1', '2', '2')
INSERT INTO 'entrada' ('nordem_n', 'lote', 'val', 'designacao', 'familiamarca', 'quantguia', 'quantconf', 'atado', 'posicao', 'codprod') VALUES

as we can see the second query, don't have any value. the worst of all the table entrada is empty

Show your new code...

     <?php
    //conecção ao servidor
    $conn = mysql_connect("localhost", "root")or die("sem conecção ao servidor");
    $db = mysql_select_db("sermail")or die("Base de dados não foi encontrada");
    // VAr
    //table ordem
    $data = date("dmY");
    $nordem = $_POST['nordem'];
    $guian = $_POST['guian'];
    $ncliente = $_POST['ncliente'];
    $cliente = $_POST['cliente'];
    $fornecedor = $_POST['fornecedor'];
    // table entrada
    $check = $_POST['check'][$i];
    $lote = $_POST['lote'][$i];
    $val = $_POST['val'][$i];
    $designacao = $_POST['designacao'][$i];
    $filtro = $_POST['filtro'][$i];
    $familiamarca = $_POST['familiamarca'][$i];
    $quantguia = $_POST['quantguia'][$i];
    $quantconf = $_POST['quantconf'][$i];
    $atado = $_POST['atado'][$i];
    $posicao = $_POST['posicao'][$i];
    $codprod = $_POST['codprod'][$i];
    //insert data table ordem
    echo $sql="INSERT INTO ordem(data, nordem, fornecedor, guian, ncliente, cliente)
    VALUES( '".$data."', '".$nordem."', '".$fornecedor."', '".$guian."', '".$ncliente."', '".$cliente."')";
    echo "</br>";
    mysql_query ($sql);


    //insert data table entrada
    echo $sql2a = 'INSERT INTO \'entrada\' (\'nordem_n\', \'lote\', \'val\', \'designacao\', \'familiamarca\', \'quantguia\', \'quantconf\', \'atado\', \'posicao\', \'codprod\') VALUES';
    for ($i=0; $i<count($_POST['check']); $i++) {
    $sql2a .= '(\'' . $_POST['lote'][$i] . '\', \'' . $_POST['val'][$i] . '\', \'' . $_POST['designacao'][$i] . '\', \'' . $_POST['familiamarca'][$i] . '\', \'' . $_POST['quantguia'][$i] . '\', \'' . $_POST['quantconf'][$i] . '\', \'' . $_POST['atado'][$i] . '\', \'' . $_POST['posicao'][$i] . '\', \'' . $_POST['codprod'][$i] . '\')';
    if ($i<count($_POST['check']) - 1) {
    $sql2a .= ',';
    }
    }
    ?>
    <?php
    mysql_close();
    ?>
  1. Before line 43, add mysql_query ($sql2a);

You still didn't do what I told you to, as quoted above. You don't execute the query...

The echo doesn't show the values, because they are added after your echo.

does not work... tryed in line 42 and 40.. same result, the notification refers to $i which is supossed to be the row var.. i believe that i must solve it first in order to proced, but there, i'm really stuck.

<?php
    //conecção ao servidor
    $conn = mysql_connect("localhost", "root")or die("sem conecção ao servidor");
    $db = mysql_select_db("sermail")or die("Base de dados não foi encontrada");
    // VAr
    //table ordem
    $data = date("dmY");
    $nordem = $_POST['nordem'];
    $guian = $_POST['guian'];
    $ncliente = $_POST['ncliente'];
    $cliente = $_POST['cliente'];
    $fornecedor = $_POST['fornecedor'];
    // table entrada
    $check = $_POST['check'][$i];
    $lote = $_POST['lote'][$i];
    $val = $_POST['val'][$i];
    $designacao = $_POST['designacao'][$i];
    $filtro = $_POST['filtro'][$i];
    $familiamarca = $_POST['familiamarca'][$i];
    $quantguia = $_POST['quantguia'][$i];
    $quantconf = $_POST['quantconf'][$i];
    $atado = $_POST['atado'][$i];
    $posicao = $_POST['posicao'][$i];
    $codprod = $_POST['codprod'][$i];
    //insert data table ordem
    echo $sql="INSERT INTO ordem(data, nordem, fornecedor, guian, ncliente, cliente)
    VALUES( '".$data."', '".$nordem."', '".$fornecedor."', '".$guian."', '".$ncliente."', '".$cliente."')";
    echo "</br>";
    mysql_query ($sql);


    //insert data table entrada
    echo $sql2a = 'INSERT INTO \'entrada\' (\'nordem_n\', \'lote\', \'val\', \'designacao\', \'familiamarca\', \'quantguia\', \'quantconf\', \'atado\', \'posicao\', \'codprod\') VALUES';
    for ($i=0; $i<count($_POST['check']); $i++) {
    $sql2a .= '(\'' . $_POST['lote'][$i] . '\', \'' . $_POST['val'][$i] . '\', \'' . $_POST['designacao'][$i] . '\', \'' . $_POST['familiamarca'][$i] . '\', \'' . $_POST['quantguia'][$i] . '\', \'' . $_POST['quantconf'][$i] . '\', \'' . $_POST['atado'][$i] . '\', \'' . $_POST['posicao'][$i] . '\', \'' . $_POST['codprod'][$i] . '\')';
    if ($i<count($_POST['check']) - 1) {
    $sql2a .= ',';
    }
    }
    mysql_query ($sql2a);
    ?>
    <?php
    mysql_close();

    ?>

You did not include any error/warning message (so do that next time too). But if it refers to $i, it probably refers to line 14-24. You use $i there, but it has no value at that point.

that's right, the lines betwen 14 and 24 gave me 2 notification, one in "i and the other he don't tell me where.

if the $i is the $row what shoud be is value? that's one thing i don't understand.

whell... i tried to give a value to $i=0. notification goes away, no data inserted anyway.

Why? in my mind the code makes sense, you corrected it, it should be good wright?

I think lines 14 - 24 can be safely removed, as those variables are never used.

it works(the same way) anyway.
no data inserted in table entrada......

forget to put info about the tables..

table ordem
data, fornecedor, guian, ncliente, cliente, nordem=> primary
nordem_n, lote, val, designacao, familiamarca, quantguia, quantconf, atado, posicao, codprod, id=> primary auto increase

maybe is beter to tell my idea.

once checked a line must be inserted in the table, i can check between 1 and 6 lines of the form table.
other idea, is to only isert data in ordem table only if one line of the entrada table is checked.

mysql_query ($sql2a);

Change that line to two lines:

echo $sql2a . '<br/>';
mysql_query($sql2a) or die(mysql_error());

And show the output.

the worst error i can get....

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''entrada' ('nordem_n', 'lote', 'val', 'designacao', 'familiamarca', 'quantguia',' at line 1

INSERT INTO \'entrada\'

Should be:

INSERT INTO entrada

quotes removed. new error

INSERT INTO ordem(data, nordem, fornecedor, guian, ncliente, cliente) VALUES( '31072012', '13', '23', '1', '2', '2')
INSERT INTO entrada (nordem_n, lote, val, designacao, familiamarca, quantguia, quantconf, atado, posicao, codprod) VALUES('1', '1', '4', '7', '41', '2', '22', '2', '1'),('21', '21', '34546', '6', '45', '646', '1', '', '1')
Column count doesn't match value count at row 1

You specify 10 columns, yet provide only 9 values.

acidently erased the first value.. new/old error, i cannot understand what is wrong now.

Notice: Undefined index: check in C:\wamp\www\sermail db\entrada.php on line 36
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

     <?php
    //conecção ao servidor
    $conn = mysql_connect("localhost", "root")or die("sem conecção ao servidor");
    $db = mysql_select_db("sermail")or die("Base de dados não foi encontrada");
    // VAr
    //table ordem
    $data = date("dmY");
    $nordem = $_POST['nordem'];
    $guian = $_POST['guian'];
    $ncliente = $_POST['ncliente'];
    $cliente = $_POST['cliente'];
    $fornecedor = $_POST['fornecedor'];

    //insert data table ordem
    echo $sql="INSERT INTO ordem(data, nordem, fornecedor, guian, ncliente, cliente)
    VALUES( '".$data."', '".$nordem."', '".$fornecedor."', '".$guian."', '".$ncliente."', '".$cliente."')";
    echo "</br>";
    mysql_query ($sql);

    //insert data table entrada
    $sql2a = 'INSERT INTO entrada (nordem_n, lote, val, designacao, familiamarca, quantguia, quantconf, atado, posicao, codprod) VALUES';
    for ($i=0; $i<count($_POST['check']); $i++) {
    $sql2a .= '(\'' . $_POST['nordem_n'][$i] . '\',\'' . $_POST['lote'][$i] . '\', \'' . $_POST['val'][$i] . '\', \'' . $_POST['designacao'][$i] . '\', \'' . $_POST['familiamarca'][$i] . '\', \'' . $_POST['quantguia'][$i] . '\', \'' . $_POST['quantconf'][$i] . '\', \'' . $_POST['atado'][$i] . '\', \'' . $_POST['posicao'][$i] . '\', \'' . $_POST['codprod'][$i] . '\')';
    if ($i<count($_POST['check']) - 1) {
    $sql2a .= ',';
    } 
    } 
        echo $sql2a . '<br/>';
    mysql_query($sql2a) or die(mysql_error());


    ?>
    <?php
    mysql_close();

    ?>

Forgot to check any checkboxes... That's when you can get that error. Basically if nothing is checked you shouldn't execute the second query.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.