First my database.
[localhost:~] tor% mysql -u tor -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 3.23.42

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use nuug
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select * from Oslo_220602_Vika;
+-------------+------------------+
| navn        | epost            |
+-------------+------------------+
| Tor Hildrum | [EMAIL PROTECTED] |
| Tor Hildrum | [EMAIL PROTECTED]  |
| Tor Hildrum | [EMAIL PROTECTED]  |
+-------------+------------------+
3 rows in set (0.00 sec)

Now the code:
#!/usr/bin/perl 
use Strict;
use CGI qw(:standard);
use DBI;

my @arrangement;
my $tabell = "Oslo_220602_Vika";
my $navn = "Tor Hildrum";
my $epost = "tor\@whatever.com";

my $dbh = DBI->connect("DBI:mysql:database=nuug;host=localhost", tor,
password, {'RaiseError' => 1 });
my $sth = $dbh->prepare("select * from $tabell");
$sth->execute();
while (my $ref = $sth->fetchrow_hashref()) {
push(@arrangement, $ref->{'epost'});}

while (@arrangement) {
chomp;
my $test = 1 if $_ eq $epost;
}

if ($test == 1) {
  print $q->start_html,
        $q->h1('Feil ved registrering'),
        $q->hr,
        $q->h2("$epost er allerede registrert til arrangementet: $tabell"),
        $q->hr,
        $q->h1('Kontakt NUUG hvis du tror det har oppstaatt en feil'),
        $q->end_html;
$dbh->disconnect();
} else {
$sth->prepare("insert into $tabell('navn', 'epost') values ($navn,
$epost)");
$sth->execute();
$dbh->disconnect();

  print $q->header,
        $q->start_html,
        $q->h1("Registrering fullfoert"),
        $q->hr,
        $q->h3("Du er naa registrert til arrangement $tabell, med foelgende
informasjon: "),
        $q->h3("Navn: $navn"), p,
        $q->h3("Epost: $epost"),hr,
        $q->end_html;
}

When I try to run this script from either the command line or from a
web-browser, it just hangs. I'm not sure how to figure this out. I can't
seem to find any mysql log-files, nor will my webservers log provide any
information, and when using the command line it justs hangs without
outputting anything. Anyone that can help me with the code, or ideas of how
to troubleshoot this? I think the problem is with MySQL, but reading man
DBI, I can't see what I am doing wrong.

Tor


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to