First see this on formatting your code, like this:
$dbh->do("insert into registration (donorssn,donordob,regdt,donorname,password, question,answer,email,phone) VALUES($ssn,'$dob','$x','$dname','$pwd', '$question','$ans','$email','$ph')"); if(!$dbh) { $err = "Error:" . $dbh->errstr . "\n"; } else { $err = " Thank you for registering online Please contact the Oklahoma Blood Institute at 1-800-827-5693 for more information"; $rpath = "/obi/register.html"; }
You should not be checking the status of $dbh, which should always be a valid database handle after connecting, you should be checking the return value of $dbh->do(...), like so:
my $status = $dbh->do(....); if ($status) { # OK } else { # Error }
Also look at the DBI documentation (and What are placeholders in DBI, and why would I want to use them?) and consider using placeholders/bind values so that you don't have to worry about quoting your arguments or escaping quotes that users might feed you as input. You won't get any efficiency gain in MySQL, but its still a worthwhile thing to do.

In reply to Re: Need help in inserting records in MySQL by runrig
in thread Need help in inserting records in MySQL by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.