PDA

View Full Version : HTML and ODBC problems


Mario542
11-15-02, 15:04
I'm am trying to get simple html page to work with a script using dbi and cgi. It works fine in mysql but when I change the dbname from DBI:mysql:test to DBI:ODBC:HERM which is a totally different database the html and script stop working. Has anyone seen this problem before, and if so could someone please help? Here is the perl code that I'm using.
Thanks in advance..
Mario542

#!c:\perl\bin\perl.exe -wT
# Get the input for POST method
read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'});
#Split the name-value pairs
($name,$value)=split(/=/,$buffer);

# Substitute special character to its original character
$value=~ tr/+/ /;
$value=~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
use DBI ;
use CGI ;
CGI::ReadParse ();
$dbname="DBI:ODBC:HERM"
$user="";
$passwd="";
$statement = "UPDATE staf SET name='superman' where name='$value'";
$dbh = DBI->connect(dbname, $user, $password) || die "$DBI::errstr";
$sth = $dbh->prepare($statement) ;
$sth-> execute() ;

Bernd Dulfer
11-19-02, 04:48
It works fine in mysql but when I change the dbname from DBI:mysql:test to DBI:ODBC:HERM which is a totally different database the html and script stop working.

There must be error messages in the web server error log.
Please post these.

Also switch on RaiseError, so all errors will cause the script to die and leave an entry in the error log.
To do this change your connect to:

$dbh = DBI->connect(dbname, $user, $password, {RaiseError => 1}) || die "$DBI::errstr";