Re: Strange MySQL problem with multiple consequent inserts

From: Date: Mon, 14 May 2001 16:33:22 +0000
Subject: Re: Strange MySQL problem with multiple consequent inserts
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-9303@lists.php.net to get a copy of this message
At 05:56 PM 5/14/01 +0200, Stefano Bizzi wrote:
$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',
You're missing the opening single quote on $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: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net
------------------------------------- Brian S. Dunworth Sr. Software Development Engineer Oracle Database Administrator The Printing House, Ltd. (850) 875-1500 x225 <brian@theprintinghouse.com> -------------------------------------

« previous php.db (#9303) next »