in reply to MySQL and PERL tribulations....

In addition to the other suggestions here, you might wrap your DBI calls in an eval {} block, check for errors and then print out a helpful message to the browser if a message is found. Also, you should print out your http header before you do anything else to make this possible.

# I assume that this routine prints out the http header &header("We are done"); $query = "SELECT nw_ucountry FROM $Table"; $query .= " WHERE nw_ucountry LIKE '$country'"; my ($sth); eval { $sth = $dbh->prepare($query); $sth->execute; }; if ( $@ ) { print "<p>Error found executing SQL.\n", "<pre>$query\nError: $@</pre>"; } else { while (($qcountry) = $sth->fetchrow_array()) { ... } }

It also helps greatly if you can keep an eye on your web server's error logs. Messages output from a die (either explicitly or implicitly using the RaiseError attribute) should appear there and would be much more helpful than the message that appears to the browser.

Chris

M-x auto-bs-mode

Replies are listed 'Best First'.
RE: RE: MySQL and PERL tribulations....
by bman (Sexton) on Nov 10, 2000 at 02:20 UTC
    Thanks to all the suggestions. However, after taking a closer look at the code next day I think, I figured out the problem (well, the script is working now). I have included my "INSERT" statement within "SELECT" while loop. It seems like when running "while" loop with select, MySQL locked the table and this was the reason why I could not write anything to it. I simply took "INSERT" out of the loop and now it's O.K.

    Thanks again.