Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I am wanting to use placeholders (?) to achieve better design. Is there a better design method? When i run this script the variables are not entered into the database.-------------------------------------------------------- #!/perl/bin/perl.exe use strict; use CGI; use DBI; use DBD::ODBC; my ( $data_source, $database) = qw( server database user + password ); $data_source = "DIGGER"; $database = "My Company"; my $conn_string = "driver={SQL Server};Server=$data_source; + Database=$database"; my $dbh = DBI->connect( "DBI:ODBC:$conn_string" ) or die + $DBI::errstr; my $query = CGI->new(); print "Content-type: text/html\n\n"; print "<html><body>\n"; print "ADD NEW FILM\n"; if ($query->param('FilmName')) { my $FilmName = $query->param('FilmName'); chomp $FilmName; } if ($query->param('Price')) { my $Price = $query->param('Price'); chomp $Price; } my $sth = $dbh->do( "INSERT INTO tblFilm (Name, Price) VALUES + ('$FilmName', '$Price')") || print "Can't prepa +re statement: $DBI::errstr"; print "</body></html>\n"; $dbh->disconnect; ------------------------------------------------------
Thankyou guru's,
edit (broquaint): added formatting
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Insert into MSSQL
by ysth (Canon) on Jul 11, 2004 at 11:09 UTC | |
|
Re: Insert into MSSQL
by freddo411 (Chaplain) on Jul 11, 2004 at 16:14 UTC | |
|
Re: Insert into MSSQL
by runrig (Abbot) on Jul 11, 2004 at 18:17 UTC |