in reply to MySQL/DBI: Error if entry is not in the database

#print "Content-type:text/html\n\n";

Why did you comment out the content type?

since your using CGI.pm's :standard the easier way to print the headers is like this:
print header();
to print the body tags and any CCS, Javascripts and stuff, use the start_html clause:
print start_html(-bgcolor=>"#FFFFFF", -text=>"#000000", -style=>{code=>$somecode}, -script=>{code=>$Somejscript});


And how I test for rows is like this:

my ($sth, $row); $dbh = <useyourconnection>; $sth = $dbh->prepare (qq{ SELECT * FROM mytable }); $sth->execute(); while ($row = $sth->fetchrow_hashref()) { # these are the rows that do exists do # what you want with those rows. }

If you only want to check for ONE record you can do it like this:

$sth = $dbh->prepare (qq{ SELECT * FROM mytable WHERE some_column += ? }); # The ? is a placeholder $sth->execute($str); # $str is what your searching for $row = $sth->fetchrow_hashref(); # This executes the above $sth->finish();# This closes the connection.

That is untested, so please take it with a grain of salt.

I actually store everything in a LOCAL module I create. I have the script push the location to @inc then just use the module. Then my connections look more like this (EVER TIME):
$dbh = SOMEDIR::SOMENAME::Connect();

That way I don't have to re-write the whole dang code every single time. I just use that statement and it's much faster.

Just because I showed you that, does not mean you don't need to show more of your code to get a better answer. I'm just showing you how I do it, PLUS if you leave the print Content-type commented out, you'll get a error in your browser every time. The error logs for that should say premature end of script headers.

Hope that helps some.
Richard.

UPDATE:
Sorry, I did not NOTICE the part that you commented out the print Content-type because you ALREADY used CGI.pms functions which I recommended. My bad. Please disregard that part.

Thanks!

Added update per author request - dvergin 2003-01-23