Hi all,
i have a problem that is drivin me nuts... i tried to solve it in many
different ways but the behaviour is so strange that i cannot actually figure
out what could cause this.
The following code:

$result = mysql_query ("INSERT INTO Ordini (ORDERID, DATA, RAGSOC,
INDIRIZZO, CAP, CITTA, PROVINCIA, NAZIONE, EU, TELEFONO, FAX, EMAIL, ICQUIN,
PARTITAIVA, MODPAGAMENTO, IP) VALUES ('$ORDERID', $DATA', '$RAGIONESOCIALE',
'$INDIRIZZO', '$CAP', '$CITTA', '$PV', 'IT', 1, '$TELEFONO', '$FAX',
'$EMAIL', '$ICQUIN', '$PIVACFISC', '$PAYMENT', '$CURRENTIP')", $db) or die
("wrong query : " . mysql_error());
 print "<BR>Ordini Table : Insert ID : " . mysql_insert_id();
print "<BR>Result : $result<BR>";
foreach ($dettaglio as $elemento)
       {
       $parti = explode("|", $elemento);
       $result = mysql_query ("INSERT INTO Dettaglio (ORDERID, PARTID,
DESCRIZIONE, PREZZOIE, ALIVA) VALUES ('$ORDERID', '$parti[0]', '$parti[1]',
'$parti[2]', '20')", $db) or die (mysql_error());
       print "<BR>Detail Table - Insert ID : " . mysql_insert_id();
       print "<BR>Result : $result<BR>";
        }

is supposed to add several records to my MySQL table. As you notice, it is
written to add a first record (order record) and a subset of records realted
to that order (in the foreach cycle). I tried with 1 order and 5 details,
and add OR the order OR the details (always all the detail records are added
in this case)... never both together. The strange thing is that the output
to the browser is the following:

Ordini Table : Insert ID : 0
Result : 1
Detail Table - Insert ID : 1
Result : 1
Detail Table - Insert ID : 2
Result : 1
Detail Table - Insert ID : 3
Result : 1
Detail Table - Insert ID : 4
Result : 1
Detail Table - Insert ID : 5
Result : 1

So, from what i can understand, the queries are issued correctly (result is
always true) and also the insert_id is updated correctly. What could cause
the random insert of the records?

Thanks in advance for any suggestion :)

Stefano



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to