
wayko621
Novice
May 16, 2002, 10:39 AM
Post #13 of 28
(32584 views)
|
new code use CGI; use CGI::Carp 'fatalsToBrowser'; #!/usr/bin/perl -w $first = $field{'first'}; $last = $field{'last'}; $address = $field{'address'}; $email = $field{'email'}; $phone = $field{'phone'}; $user = $field{'user'}; $pass = $field{'pass'}; use DBI; my $DSN = 'driver=Driver do Microsoft Access (*.mdb); dbq=\\$c\\Inetpub\\wwwroot\\test.mdb'; DBI->trace(5,"c:/trace.txt"); my $dbh = DBI->connect("dbi:ODBC:$DSN", '','') || die "Can't connect to database: $DBI::errstr"; print "Content-Type: text/html\n\n"; print"<html><body><h1>this is a test</h1>"; $sql = qq{INSERT INTO Dreamcpu (FirstName,LastName,Address,Email,Phone,Username,Password) VALUES ('$first','$last','$adress','$email','$phone','$user','$pass');}; print"$rc record(s) were added.<p>"; $sth = $dbh->prepare($sql); $rc = $sth->execute(); print"<table>\n"; print"<tr><th>ID</th><th>First</th><th>Last</th><th>Address</th><th>Email</th><th>Phone</th><th>User</th><th>Password</th>\n" ; while (@row = $sth->fetchrow_array) { print"<tr>"; foreach(@row) { print"<td>$_</td>"; } print"</tr>\n"; } print"</table>\n"; print"</body></html>"; $sth->finish; $dbh->disconnect; i added the lines plus added a dbi->trace the file came out with this DBI 1.21-nothread dispatch trace level set to 5 Note: perl is running without the recommended perl -w option -> DBI->connect(dbi:ODBC:driver=Microsoft Access Driver (*.mdb); dbq=\$c\inetpub\wwwroot\test.mdb, , ****) -> DBI->install_driver(ODBC) for MSWin32 perl=5.006001 pid=3056 ruid=0 euid=0 install_driver: DBD::ODBC version 0.28 loaded from C:/Perl/site/lib/DBD/ODBC.pm New DBI::dr (for DBD::ODBC::dr, parent=, id=) dbih_setup_handle(DBI::dr=HASH(0x18070ec)=>DBI::dr=HASH(0x17b5cd8), DBD::ODBC::dr, 0, Null!) dbih_make_com(Null!, DBD::ODBC::dr, 92) dbih_setup_attrib(DBI::dr=HASH(0x17b5cd8), Err, Null!) SCALAR(0x1552ee0) (already defined) dbih_setup_attrib(DBI::dr=HASH(0x17b5cd8), State, Null!) SCALAR(0x17c0dd4) (already defined) dbih_setup_attrib(DBI::dr=HASH(0x17b5cd8), Errstr, Null!) SCALAR(0x17c0d98) (already defined) dbih_setup_attrib(DBI::dr=HASH(0x17b5cd8), Handlers, Null!) ARRAY(0x17b5c54) (already defined) dbih_setup_attrib(DBI::dr=HASH(0x17b5cd8), Debug, Null!) 0 (already defined) dbih_setup_attrib(DBI::dr=HASH(0x17b5cd8), FetchHashKeyName, Null!) 'NAME' (already defined) <- install_driver= DBI::dr=HASH(0x18070ec) -> connect for DBD::ODBC::dr (DBI::dr=HASH(0x18070ec)~0x17b5cd8 'driver=Microsoft Access Driver (*.mdb); dbq=\$c\inetpub\wwwroot\test.mdb' '' **** HASH(0x182ed84)) i still got the error Software error:Can't connect to database: [Microsoft][ODBC Driver Manager] Invalid string or buffer length (SQL-S1090)(DBD: db_login/SQLConnect err=-1) at C:\Inetpub\wwwroot\cgi-bin\database1.pl line 16.
  
(This post was edited by wayko621 on May 16, 2002, 11:07 AM)
|