The script below prints at the bottom and this ALWAYS shows the real order of posts, but somehow it becomes distorted in my mysql database. After 4 attempts, I've noticed the mysql setup always appears in the same wrong order, so it's not randomly throwing things in there. Anyone know what might be the problem?
#!/usr/bin/perl -w use strict; use warnings; use POSIX; use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); use DB_File; use DBI; my $add; my %chat; my $chat = "chat.db"; tie %chat, "DB_File", "$chat", O_CREAT|O_RDWR, 0644, $DB_BTREE or die "Cannot open file 'chat': $!\n"; my $dbase = "*"; my $mysql_user = "*"; my $mysql_pass = "*"; print header, start_html(); ### # connect to database ### my $dbh = DBI->connect("DBI:mysql:$dbase", $mysql_user, $mysql_pass) o +r print DBI->errstr; foreach my $key (reverse sort keys %chat) { my ( $name, $message, $userip) = split /~~/, $chat{$key}; my $data = qq(INSERT INTO chat (name, message, mood, ip, posttime) VAL +UES(?,?,?,?,?)); my $sth = $dbh->prepare($data); $sth->execute($name, $message, "happy", $userip, "0:0:0") or die $dbh- +>errstr; print qq($name $message $userip<br><br>); }
In reply to database not in correct order by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |