Re: dbi::errstr error.



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


.



Relevant Pages

  • dynamic lib ignored even after "found" in "install_driver(Oracle) failed: Cant load..." cgi problem
    ... here's a problem it seems a lot of people are seeing when running a CGI script ... after installing the the sqlplus client on my linux machine (and testing it on the command line, successfully connecting to our oracle db), and then installing the perl moduleneeded to make connections in perl scripts and cgis, i find, like so many others i've seen complain about this, that my cgi script runs fine from the command line, but fails when it is run as a CGI via my machine's apache webserver. ...
    (perl.dbi.users)
  • Re: a short non-working Perl script
    ... and learn the *right* way to write a CGI script in Perl. ... A minor niggle - Perl does not seem to match END_OF_PART2 unless I ... Those four should be in EVERY Perl CGI script you write. ... Get rid of this entire mess and replace with: ...
    (comp.lang.perl.misc)
  • Re: CGI POST problem was: How to read POSTed data
    ... >> how is a multipart POST request parsed by CGIHTTPServer? ... > is passed to the CGI script, which can choose to parse it or not using ... So I have to use that instead of FieldStorage? ...
    (comp.lang.python)
  • Re: How to call an internal CGI subroutine?
    ... > How are subroutines called within a single CGI script? ... > ...etc closing html stuff ... > sub someroutine { ...
    (comp.lang.perl.misc)
  • How do I configure thttpd to run cgi scripts ?
    ... I am trying to configure thttpd to allow me to run CGI scripts. ... I have a configuration file /etc/thttpd/thttpd.conf, ... # Sets whether thttpd will chroot after starting. ... Can I move the cgi script to outside of the www path, ...
    (comp.os.linux)