Re: Strange MySQL problem with multiple consequent inserts
| From: | Stefano Bizzi | Date: | Mon, 14 May 2001 17:04:12 +0000 |
| Subject: | Re: Strange MySQL problem with multiple consequent inserts | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-9305@lists.php.net to get a copy of this message | ||
Thanks... but that's is just a copy & paste mistake... the original one
doesnt... :)
infact the query runs and insert the $DATA field correctly
Thanks :)
Stefano
""Brian S. Dunworth"" <brian@theprintinghouse.com> ha scritto nel
messaggio
news:4.3.0.20010514123238.00a8d950@smtp.postoffice.net...
> 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>
> -------------------------------------
>
>
> --
> 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
>