Re: dbi::errstr error.
- From: scoles@xxxxxxxxxxx (John Scoles)
- Date: Fri, 27 Jan 2006 10:22:21 -0500
try
$sth->execute() or die "Unable to insert the value: $dbi::errstr\n";
rather than
$sth->execute()||die "Unable to insert the value: $dbi::errstr\n";
I took the liberty of rewriting part of your code a little so it is more
readable and it is using params. This is a much more secure way to do CGI
programming.
my $sql="insert into user
(name, email, phone, address, username,password)
values(:p_name, :p_email, :p_phone, :p_address, :p_username,
:p_password)";
$sth=$dbh->prepare($sql);
$sth->bind_param(":p_name",$name);
$sth->bind_param(":p_email",$email);
$sth->bind_param(":p_phone",$phone);
$sth->bind_param(":p_address",$address);
$sth->bind_param(":p_username",$username);
$sth->bind_param(":p_password",$password);
$sth->execute() or die "Unable to insert the value: $dbi::errstr\n";
$dbh=disconnect();
"Dilly raja" <rajadilly@xxxxxxxxx> wrote in message
news:a4f614df0601270157o65518d85s1e513ba62c57efc5@xxxxxxxxxxxxxxxxx
I have a cgi script adduser.cgi which collects the data from the user
through adduser.html. when i execute this script i encountered the error as
shown below.
Name "dbi::errstr" used only once: possible typo at adduser.cgi line 18.
the complete script of the adduser.cgi is shown below. Since i am new to
perl and mysql i cant able to find out the reason for the error. i will
thankful if you find out the reason for this.
the cgi script is
#!c:/perl/bin/perl -w
use CGI;
use DBI;
my $cgi=new CGI;
$name = $cgi->param("name");
$email=$cgi->param("email");
$phone=$cgi->param("phone");
$address=$cgi->param("address");
$username=$cgi->param("username");
$password=$cgi->param("password");
my $dbh=DBI->connect ("DBI:mysql:dvd","","autoraja")||
die "Error opening database: $DBI::errstr\n";
$sth=$dbh->prepare("insert into user(name, email, phone, address, username,
password)
values($name, $email, $phone, $address, $username, $password)");
$sth->execute()||die "Unable to insert the value: $dbi::errstr\n";
$dbh=disconnect();
print "Content-type: text/html\n\n";
print "<HTML>";
print "<HEAD><TITLE>CGI Process: $name\n</TITLE></HEAD>";
print "<BODY>";
if($name eq "")
{
print "<H1>Invalid Name. Please Try Again.</H1></BODY></HTML>";
exit (0);
}
print "The name is <b>", $name, "</b>";
print "</BODY></HTML>";
--
Friendly,
Raja.M
.
- Follow-Ups:
- Re: dbi::errstr error.
- From: Ron Savage
- Re: dbi::errstr error.
- References:
- REG: dbi::errstr error.
- From: Dilly raja
- REG: dbi::errstr error.
- Prev by Date: RE: Future versions of DBI to require perl >= 5.8
- Next by Date: RE: dbi::errstr error.
- Previous by thread: REG: dbi::errstr error.
- Next by thread: Re: dbi::errstr error.
- Index(es):
Relevant Pages
|
|