See my comments below...
Marcus Willemsen [[EMAIL PROTECTED]] wrote:
> Hi all,
>
> I am having troubles with the script below. (I hope nobody minds that the
> names of the variables and params are in German)
>
> The script reads data coming from a form and inserts it inot the
> appropriate tables. Well it works for almost all values except for
> $ueberschrift and $text. The fields in the tables are empty. Another
> problem is that 4 sets of data are created each time the script is called.
> Four empty ones and one partially filled as described before.
>
> I have rewritten the script to be executed from the shell and it works
> perfectly. Each time it is executed one, complete set of data is created.
> The SQL Commands are the same...
> Anyone any suggestions???
>
> Thanks Marcus
>
>
> #!/usr/bin/perl -w
>
> use strict;
> use CGI qw(:standard);
> use CGI::Carp qw(fatalsToBrowser);
> use DBI;
>
> my ($dbh ,$sth ,$funktionID ,$redakteurID, $bearbeiterID, $datum,
> $versionID, $publID, $ausgabeID, $seiten, $erschienenID, $abbildung,
> $abbildungID, $bildunter, $bildID, $rubrikID, $nachricht, $ueberschrift,
> $laenge, $ausgabe);
>
> $dbh = DBI->connect("DBI:mysql:newsdb", "xxx", "xxx") or die "Error:
> $DBI::errstr\n";
>
> $versionID = param('version');
> $funktionID = param('funktion');
> $redakteurID = param('redakteur');
> $dbh->do("INSERT INTO bearbeiter (funktionID, redakteurID) ".
> "VALUES ('$funktionID', '$redakteurID')");
> $bearbeiterID = $dbh->{'mysql_insertid'};
>
> $publID = param('publ');
> $ausgabe = param('ausgabe');
> $dbh->do("INSERT INTO ausgabe (ausgabe) VALUES ('$ausgabe')");
> $ausgabeID = $dbh->{'mysql_insertid'};
>
> $seiten = param('seiten');
> $dbh->do("INSERT INTO erschienen (seitenangabe, ausgabeID, publikationID)
> VALUES ('$seiten', '$ausgabeID', '$publID')");
> $erschienenID = $dbh->{'mysql_insertid'};
>
> $abbildung = param('abbildung');
> $dbh->do("INSERT INTO abbildung (abbildung) VALUES ('$abbildung')");
> $abbildungID = $dbh->{'mysql_insertid'};
> $bildunter = ('bildunter');
> $dbh->do("INSERT INTO bild (bildunterschrift, abbildungID)
> VALUES('$bildunter', '$abbildungID')");
> $bildID = $dbh->{'mysql_insertid'};
>
> $rubrikID = param('rubrik');
> $ueberschrift = param('ueberschrift');
> $nachricht = param('nachricht');
> $datum = param('datum');
> $laenge = param('laenge');
> $dbh->do("INSERT INTO nachricht SET nachricht='$nachricht',
Why is this INSERT formatted differently than all the other
INSERT's? A "SET" is usually done in an UPDATE - did you copy
this code from an UPDATE? My guess is that if you change this
INSERT to be formatted similarly to the others, it will work
properly.
HTH.
--
Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com
> ueberschrift='$ueberschrift', laenge='$laenge',
> erschienenID='$erschienenID', rubrikID='$rubrikID',
> bearbeiterID='$bearbeiterID', versionID='$versionID', bildID='$bildID',
> zeit='$datum'");
> $dbh->disconnect;
> print header;
> print start_html;
> print qq(Danke!);
> print hr;
> print qq(<a href="../form_newsdb.html"?>Weitere Eingabe?</a>);
> print end_html;
>
> Marcus Willemsen
> Juve Verlag
> Agrippa Str. 10
> 50676 Köln
>
> tel: ++49(0)221 91 38 80 10
> fax: ++49(0)221 91 38 80 18
> www.juve.de
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]