true..

i get no error's but i get no data inserted... what can i do more?

Duplicate entry '0' for key 'nordem_n'

this one... just this one... ordem_n isn't a primary.

That message indicates there is already a record where that column is zero. Apparently there is a unique key set for that column. Or an auto increment column. If it is the latter, then you can safely remove nordem_m from your query.

none of thos options, droped the field, and create a new one, now, almost fine.

SEEMS THAT ALL I EVER NEED TO DO WAS ENTER THIS FORUM.... IT'S ALIVE!

not perfect but works... it inserts an extra line were values are 0,

ONe more doubth, why it indert all rows even if I only check one??

it insert's all with valeus of 0 in all fields exept nordem_n.

Probably because you loop all checkboxes, but don't check to see if they are on or off.

how can i check it?

 if (check=1) {
 $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'] . '\',\'' . $_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 .= ',';
    } 
    } 
    }

is this a good way?

No. You must check inside the loop:

for ($i = 0; $i < count($_POST['check']); $i++) {
    // IIRC you made your checkbox 0 for off, and 1 for on
    if ($_POST['check'][$i] == 0) continue;

    $sql2a .= '...';
    if ($i < count($_POST['check']) - 1) {
        $sql2a .= ',';
    } 
} 

seems logical... ihave to read more aboout php.

I've inserted the line and the result is:

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

stuck...

$sql2a = 'INSERT INTO entrada (nordem_n, lote, val, designacao, familiamarca, quantguia, quantconf, atado, posicao, codprod) VALUES';
    for ($i=0; $i<count($_POST['check']); $i++) {
     if ($_POST['check'][$i] == 0) continue;
     $sql2a .= '(\'' . $_POST['nordem'] . '\',\'' . $_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 .= ',';
    } 
    } 

the erros seems to be in the \'' . $_POST['lote'][$i] . '\' and other's, because nordem is inserted and nothing more..

Without seeing the generated query it is very difficult to guess.

INSERT INTO entrada (nordem_n, lote, val, designacao, familiamarca, quantguia, quantconf, atado, posicao, codprod) VALUES('10','', '', '', '', '', '', '', '', ''),('10','', '', '', '', '', '', '', '', ''),
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

One of the empty strings is the problem. Is one of the columns perhaps an integer ? Or is it the comma at the end ?

all most all of them are int in mysql. that's a problem?

Yes. You either need a value without quotes, or NULL (without quotes) for no value, if it is allowed in the table.

sorry now i'm a bit confused, if the var is an int i know i cannot enter is value with quotes, but when i was filing the form i just use numbers.
on the other hand, it worked before...but i need the check box.

Try first when all fields have a value. Or is the problem that you enter values, but they are not in the SQL ?

i fill the for and click submmit, then the sql error pops up.
just nunbers in fields.

if I change form

if ($_POST['check'][$i] == 0) continue;

to

if ($_POST['check'][$i] == 1) continue;

it inserts all the tables again---without errors

Add:

print_r($_POST);

somewhere before the loop, and show what it outputs.

seems solved.. problems in the html file.

INSERT INTO ordem(data, nordem, fornecedor, guian, ncliente, cliente) VALUES( '01082012', '123', '132', '132', '132', '132')
Array ( [nordem] => 123 [fornecedor] => 132 [guian] => 132 [ncliente] => 132 [cliente] => 132 [check] => Array ( [0] => 1 [1] => 1 ) [codprod] => Array ( [0] => 1 [1] => 12345468 [2] => [3] => [4] => [5] => ) [lote] => Array ( [0] => 1 [1] => 45646 [2] => [3] => [4] => [5] => ) [val] => Array ( [0] => 1 [1] => 874 [2] => [3] => [4] => [5] => ) [designacao] => Array ( [0] => 1 [1] => 54 [2] => [3] => [4] => [5] => ) [filtro] => Array ( [0] => 1 [1] => 231 [2] => [3] => [4] => [5] => ) [familiamarca] => Array ( [0] => 1 [1] => 3 [2] => [3] => [4] => [5] => ) [quantguia] => Array ( [0] => 1 [1] => 1 [2] => [3] => [4] => [5] => ) [quantconf] => Array ( [0] => 1 [1] => 32 [2] => [3] => [4] => [5] => ) [atado] => Array ( [0] => 1 [1] => 1 [2] => [3] => [4] => [5] => ) [posicao] => Array ( [0] => 1 [1] => [2] => [3] => [4] => [5] => ) ) INSERT INTO entrada (nordem_n, lote, val, designacao, familiamarca, quantguia, quantconf, atado, posicao, codprod) VALUES('123','1', '1', '1', '1', '1', '1', '1', '1', '1'),('123','45646', '874', '54', '3', '1', '32', '1', '', '12345468')

i really don't understand it..... exact same code just other var's....

INSERT INTO paletes(data, palete, cliente, designacao, posicao, atado, total, codprod) VALUES( '01082012', '11', '1', '1', '1', '1','1', '113')

( ! ) SCREAM: Error suppression ignored for
( ! ) Notice: Array to string conversion in C:\wamp\www\sermail db\palete.php on line 25
Call Stack

Time Memory Function Location

1 0.0008 170432 {main}( ) ..\palete.php:0
INSERT INTO movimento (datam,palete_n ,saida, stock, nome) VALUES( 'Array','11','', '', ''),
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 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 Palete
    $data = date("dmY");
    $palete=$_POST['palete'];
    $nordem=$_POST['nordem'];
    $cliente=$_POST['cliente'];
    $designacao=$_POST['designacao'];
    $posicao=$_POST['posicao'];
    $atado=$_POST['atado'];
    $total=$_POST['total'];
    $codprod=$_POST['codprod'];
      //insert data table palete
    echo $sql="INSERT INTO paletes(data, palete, cliente, designacao, posicao, atado, total, codprod)
    VALUES( '".$data."', '".$palete."', '".$cliente."', '".$designacao."', '".$posicao."', '".$atado."','".$posicao."', '".$codprod."')";
    echo "</br>";
    mysql_query ($sql) or die (mysql_error());
     //insert data table movimento
     $sql2a = 'INSERT INTO movimento (datam, palete_n ,saida, stock, nome) VALUES';
    for ($i=0; $i<count($_POST['check']); $i++) {
     if ($_POST['check'][$i] == 0) continue;
     $sql2a .= '( \'' . $_POST['datam'] .'\',\'' . $_POST['palete'] .'\',\'' . $_POST['saida'][$i] . '\', \'' . $_POST['stock'][$i] . '\', \'' . $_POST['nome'][$i] . '\')';
    if ($i<count($_POST['check']) - 1) {
    $sql2a .= ',';
    } 
    } 
        echo $sql2a . '<br/>';
    mysql_query($sql2a) or die(mysql_error());





    ?>
    <?php
    mysql_close();

    ?>

html code.

<!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="author" content="Alex" />
        <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;
   }
   .bodyn{visibility: hidden;
   display: none;
   }
    .background{ color: #0000;}
    .page landscape {size: landscape;}
    .page
    { bgcolor: #0000; }
    .h2{color: #000;
    font-family: Times New Roman, sans-serif;
    font-size: 18px;
    font-weight: bold;
    text-align: left;}



</style>


    </head>
<body bgcolor= #00814B>
 <div class="bodyn">
  <form action="paleteupdate.php" method="post">
    <h3>N.º Palete <input type="text" size="6" name="spalete"><input type="submit"/ class="printbutton" value="procurar"></h3>

  </form>
 </div>
    <div class="body">
        <div class="content">
        <br><br><br><br><br>
<form action="palete.php" method="post">


 <table width="1000px"> <tr><td width="600px">
 </td><td width="400px"><img src="imas/sermaillogo.png"></td></tr>
 </table>

 <table  width="1000px">
  <tr>
   <td>
    <table border="1">
     <tr>
      <td><h2>Folha de Palete n.º</h2></td>
      <td ><input type="text" size="8"name="palete"></td>
     </tr>
     <tr>
      <td colspan="2" ><h2>Dados de Entrada</h2>
      </td>
     </tr>
     <tr>
      <td >
      <h2>N.º Ordem</h2>
      </td>
      <td >
      <input type="text" size="6"name="nordem">
      </td>
     </tr>
     <tr>
      <td><h2>data</h2>
      </td>
      <td>
      <h2>  ainda por defenir <h2/>
      </td>
     </tr>
     <tr>
      <td>
      <h2>Cliente</h2>
      </td>
      <td>
      <input type="text" size="15"name="cliente">
      </td>
     </tr>
     <tr>
      <td>
      <h2>Produto</h2>
      </td>
      <td>
      <input type="text" size="30"name="designacao">
      </td>
     </tr>
     <tr>
      <td>
      <h2>Codigo</h2>
      </td>
      <td>
      <input type="text" size="8"name="codprod">
      </td>
     </tr>
     <tr>
      <td>
      <h2>Posição</h2>
      </td>
      <td>
      <input type="text" size="5"name="posicao">
      </td>
     </tr>
     <tr>
      <td>
      <h2>Qt. Atado</h2>
      </td>
      <td>
      <input type="text" size="6"name="atado">
      </td>
     </tr>
     <tr>
      <td>
      <h2>Qt. Total</h2>
      </td>
      <td>
      <input type="text" size="8"name="total">
      </td>
     </tr>
   </table>
  </td> 

  <td>
   <table border="1" ><tr>
   <td colspan="4" ><h2>Movimento do produto</h2></td></tr>
   <tr><td><h2>Data</h2></td><td><h2>Quantidade<br/> Saida</h2></td><td><h2>Stock</h2></td><td><h2>Nome<h2></td></tr>
   <tr><td><input type="text" size="10"name="datam[]"></td><td><input type="text" size="10"name="saida[]"></td><td><input type="text" size="8"name="stock[]"></td><td><input type="text" size="10"name="nome[]"></td><td><input type="checkbox" name="check[]"  value="1"  /></td></tr>
   <tr><td><input type="text" size="10"name="datam[]"></td><td><input type="text" size="10"name="saida[]"></td><td><input type="text" size="8"name="stock[]"></td><td><input type="text" size="10"name="nome[]"></td><td><input type="checkbox" name="check[]"  value="1"  /></td></tr>
   <tr><td><input type="text" size="10"name="datam[]"></td><td><input type="text" size="10"name="saida[]"></td><td><input type="text" size="8"name="stock[]"></td><td><input type="text" size="10"name="nome[]"></td><td><input type="checkbox" name="check[]"  value="1"  /></td></tr>
   <tr><td><input type="text" size="10"name="datam[]"></td><td><input type="text" size="10"name="saida[]"></td><td><input type="text" size="8"name="stock[]"></td><td><input type="text" size="10"name="nome[]"></td><td><input type="checkbox" name="check[]"  value="1"  /></td></tr>
   <tr><td><input type="text" size="10"name="datam[]"></td><td><input type="text" size="10"name="saida[]"></td><td><input type="text" size="8"name="stock[]"></td><td><input type="text" size="10"name="nome[]"></td><td><input type="checkbox" name="check[]"  value="1"  /></td></tr>
   <tr><td><input type="text" size="10"name="datam[]"></td><td><input type="text" size="10"name="saida[]"></td><td><input type="text" size="8"name="stock[]"></td><td><input type="text" size="10"name="nome[]"></td><td><input type="checkbox" name="check[]"  value="1"  /></td></tr>
   <tr><td><input type="text" size="10"name="datam[]"></td><td><input type="text" size="10"name="saida[]"></td><td><input type="text" size="8"name="stock[]"></td><td><input type="text" size="10"name="nome[]"></td><td><input type="checkbox" name="check[]"  value="1"  /></td></tr>
   <tr><td><input type="text" size="10"name="datam[]"></td><td><input type="text" size="10"name="saida[]"></td><td><input type="text" size="8"name="stock[]"></td><td><input type="text" size="10"name="nome[]"></td><td><input type="checkbox" name="check[]"  value="1"  /></td></tr>
   <tr><td><input type="text" size="10"name="datam[]"></td><td><input type="text" size="10"name="saida[]"></td><td><input type="text" size="8"name="stock[]"></td><td><input type="text" size="10"name="nome[]"></td><td><input type="checkbox" name="check[]"  value="1"  /></td></tr>
   <tr><td><input type="text" size="10"name="datam[]"></td><td><input type="text" size="10"name="saida[]"></td><td><input type="text" size="8"name="stock[]"></td><td><input type="text" size="10"name="nome[]"></td><td><input type="checkbox" name="check[]"  value="1"  /></td></tr>
   <tr><td><input type="text" size="10"name="datam[]"></td><td><input type="text" size="10"name="saida[]"></td><td><input type="text" size="8"name="stock[]"></td><td><input type="text" size="10"name="nome[]"></td><td><input type="checkbox" name="check[]"  value="1"  /></td></tr>
   <tr><td><input type="text" size="10"name="datam[]"></td><td><input type="text" size="10"name="saida[]"></td><td><input type="text" size="8"name="stock[]"></td><td><input type="text" size="10"name="nome[]"></td><td><input type="checkbox" name="check[]"  value="1"  /></td></tr>
   <tr><td><input type="text" size="10"name="datam[]"></td><td><input type="text" size="10"name="saida[]"></td><td><input type="text" size="8"name="stock[]"></td><td><input type="text" size="10"name="nome[]"></td><td><input type="checkbox" name="check[]"  value="1"  /></td></tr>
   <tr><td><input type="text" size="10"name="datam[]"></td><td><input type="text" size="10"name="saida[]"></td><td><input type="text" size="8"name="stock[]"></td><td><input type="text" size="10"name="nome[]"></td><td><input type="checkbox" name="check[]"  value="1"  /></td></tr>
   <tr><td><input type="text" size="10"name="datam[]"></td><td><input type="text" size="10"name="saida[]"></td><td><input type="text" size="8"name="stock[]"></td><td><input type="text" size="10"name="nome[]"></td><td><input type="checkbox" name="check[]"  value="1"  /></td></tr>
   <tr><td><input type="text" size="10"name="datam[]"></td><td><input type="text" size="10"name="saida[]"></td><td><input type="text" size="8"name="stock[]"></td><td><input type="text" size="10"name="nome[]"></td><td><input type="checkbox" name="check[]"  value="1"  /></td></tr>

  </td>
  </tr> 
   </table>
 </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>

only diferences between the 2 forms are the var's and grafic, but one works fine the other don't.

INSERT INTO movimento (datam,palete_n ,saida, stock, nome) VALUES( 'Array','11','', '', ''),

The comma at the end is wrong, 'Array' is not valid (looks like [$i] is missing), and saida, stock and nome are empty strings.

2 [$i] missing, they i've put then in place. $result =
INSERT INTO paletes(data, palete, cliente, designacao, posicao, atado, total, codprod) VALUES( '01082012', '21', '1', '1', '1', '1','1', '113')
INSERT INTO movimento (datam, palete_n ,saida, stock, nome) VALUES( '','1','', '', ''),
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

The comma at the end is still a problem.

if ($i<count($_POST['check']) - 1) {

this comma?