Use of uninitialized value in concatenation (.) at register.pl line 38, <STDIN> line 10.

Discussion in 'Perl' started by G Kannan, Oct 11, 2003.

  1. G Kannan

    G Kannan Guest

    Hey all!

    I have written a perl script to retrieve information from a HTML Form
    and insert the data into an Oracle database table. I am gettting the
    the following error message:

    "Use of uninitialized value in concatenation (.) at register.pl line
    38, <STDIN> line 10."

    The PERL code is as follows:

    #!/usr/bin/perl -w
    $| = 1;
    use strict;
    use DBI;
    use CGI qw:)standard);

    my $name1 = "";
    my $name2 = "";
    my $strt1 = "";
    my $strt2 = "";
    my $cityname = "";
    my $statename = "";
    my $zipcode = "";
    my $emailadd = "";
    my $useridname = "";
    my $passwd = "";
    my $query = "";
    my $queh = "";
    my $queout = "";
    my $rec = "";
    my $table ="";
    my $query1 = "";
    my $ques = "";

    $name1 = param("FirstName");
    $name2 = param("LastName");
    $strt1 = param("StreetAddress1");
    $strt2 = param("StreetAddress2");
    $cityname = param("City");
    $statename = param("State");
    $zipcode = param("Zip");
    $emailadd = param("Email");
    $useridname = param("UserId");
    $passwd = param("Password");

    my $dbh = DBI->connect('DBI:Oracle:host=172.17.28.199;sid=ORA1','f03-cs631r-s02','architecture')
    or die "Connection to DB could not be made:", $ques->errstr, "\n";
    $query = qq[select * from customer_info where userid = $useridname];
    $queh = $dbh->prepare($query)
    or die "Select statement could not be prepared:", $queh->errstr,
    "\n";
    $queout = $queh->execute()
    or die "Select statement could not be executed: ", $queout->errstr,
    "\n";
    print header();
    if ($queout){
    print "<html><head><title>User Id already taken</title></head>";
    print "<script language=\"javascript\">";
    print "function validateform(form)";
    print "{";
    print "if (form.product.value == \"Select\")";
    print "{";
    print "alert(\"Select a country to search...\")";
    print "return false";
    print "}";
    print "return true";
    print "}";
    print "</script>";
    print "<body>";
    print "<body background = \"ProjectImages/bg2.jpg\" leftmargin =
    \"95\">";
    print "<img src= \"ProjectImages/tele2.jpg\" hspace = \"115\" align
    = \"left\">";
    print "<Form name = \"search\" method = \"post\" action =
    \"ProjectHtmls/prodsearch.html\" onSubmit = \"return
    validateform(this)\">";
    print "<select name = \"product\" size = \"1\">";
    print "<option value = \"Select\" selected =
    \"selected\">Select</option>";
    print "<option value = \"Australia\" >Australia</option>";
    print "<option value = \"Canada\" >Canada</option>";
    print "<option value = \"China\" >China</option>";
    print "<option value = \"Denmark\" >Denmark</option>";
    print "<option value = \"England\" >England</option>";
    print "<option value = \"Finland\" >Finland</option>";
    print "<option value = \"Holland\" >Holland</option>";
    print "<option value = \"India\" >India</option>";
    print "<option value = \"Israel\" >Israel</option>";
    print "<option value = \"New Zealand\" >New Zealand</option>";
    print "<option value = \"Nigeria\" >Nigeria</option>";
    print "<option value = \"Poland\" >Poland</option>";
    print "<option value = \"Russia\" >Russia</option>";
    print "<option value = \"South Africa\" >South Africa</option>";
    print "<option value = \"Singapore\" >Singapore</option>";
    print "</select><br>";
    print "<input type = \"submit\" name = \"Submit\" value = \"Card
    Search\">";
    print "</form>";
    print "<br>";
    print "<a href = \"index.html\"><img src =
    \"ProjectImages/home.gif\" hspace=\"1\"></a><a
    href=\"ProjectHtmls/aboutus.html\"><img
    src=\"ProjectImages/aboutus.gif\" hspace=\"1\"></a><a
    href=\"ProjectHtmls/products.html\"><img
    src=\"ProjectImages/products.gif\" hspace=\"1\"></a><a
    href=\"ProjectHtmls/register.html\"><img
    src=\"ProjectImages/register.gif\" hspace = \"1\"></a><a
    href=\"ProjectHtmls/cart.html\"><img src=\"ProjectImages/cart.gif\"
    hspace=\"1\"></a><a href=\"mailto:Kannan.Govindarajan\@pace.edu\"><img
    src=\"ProjectImages/contactus.gif\" hspace=\"1\"></a><a
    href=\"ProjectHtmls/login.html\"><img src=\"ProjectImages/login.gif\"
    hspace=\"1\"></a><br>";
    print "<hr size = \"3\" color = \"#000080\" align = \"left\" width
    = \"811\" NOSHADE>";
    print "<font size = \"4\" color = \"navy\">";
    print "The user name you have selected is already taken by another
    customer. <br>";
    print "Please select another user name.<br>";
    print "</font>";
    print "<font size = \"3\" color = \"navy\">";
    print "<a href = \"ProjectHtmls/register.html\">Back to
    Registration Page</a>";
    print "</font>";
    print "</body>";
    print "</html>";
    }
    else {
    $table = "customer_info";
    $query1 = "INSERT INTO " . $table .
    "VALUES('.$name1.','.$name2.','.$strt1.','.$strt2.','.$cityname.','.$statename.','.$zipcode.','.$emailadd.','.$useridname.','.$passwd.')";
    $dbh->do($query1);
    }
    $queh->finish();
    $dbh->disconnect();

    The HTML code is as follows:

    <html>
    <head>
    <title>
    Registration page of TeleCards.com
    </title>
    </head>
    <script langugage = "javascript">
    //-----------------------------------------function
    validateform(form)------------------------------------------------
    function validateform(form)
    {
    if (form.product.value == "Select")
    {
    alert("Select a country to search...")
    return false
    }
    return true
    }

    //-----------------------------------------function
    isNumber(str)-----------------------------------------------------
    function isNumber(str)
    {
    for(var i=0; i<str.length; i++)
    {
    var digit = str.substring(i, i+1)
    if(digit < "0" || digit > "9")
    {
    return false
    }
    }
    return true
    }

    //-----------------------------------------function
    registerValidate()------------------------------------------------
    function registerValidate()
    {
    for(i=0; i<register.elements.length; i++)
    {
    if((register.elements.value == "") ||
    (register.elements.value == null))
    {
    if(i==3)
    continue
    alert("Please fill the field " + register.elements.name +
    ".")
    return false
    }
    }

    var notAllowed = "0123456789~!@#$%^&*()-_=+[]{}\|;:,<>./? "
    var first = register.FirstName.value
    var last = register.LastName.value
    for(i=0; i<notAllowed.length; i++)
    {
    var badChar = notAllowed.charAt(i)
    if(first.indexOf(badChar) != -1)
    {
    alert("The Character " + badChar + " is not allowed in First
    Name")
    return false
    }
    }
    for(i=0; i<notAllowed.length; i++)
    {
    var badChar = notAllowed.charAt(i)
    if(last.indexOf(badChar) != -1)
    {
    alert("The Character " + badChar + " is not allowed in Last
    Name")
    return false
    }
    }

    var notAllowed = "~!@$%^&*()=+[]{}\|;:,<>./?"
    var street = register.StreetAddress1.value
    for(i=0; i<notAllowed.length; i++)
    {
    var badChar = notAllowed.charAt(i)
    if(street.indexOf(badChar) != -1)
    {
    alert("The Character " + badChar + " is not allowed in Street
    Address1.")
    return false
    }
    }

    var notAllowed = "0123456789~!@#$%^&*()-_=+[]{}\|;:,<>./?"
    var city = register.City.value
    for(i=0; i<notAllowed.length; i++)
    {
    var badChar = notAllowed.charAt(i)
    if(city.indexOf(badChar) != -1)
    {
    alert("The Character " + badChar + " is not allowed in City.")
    return false
    }
    }

    if(register.State.value == "Select")
    {
    alert("Please select a State.")
    return false
    }

    if(register.Zip.value.length != 5)
    {
    alert("The Zip code should be exactly 5 digits in length.")
    return false
    }

    zip1 = register.Zip.value
    if(!(isNumber(zip1)))
    {
    alert("The Zip code should be only numbers")
    return false
    }

    var email = register.Email.value
    var fPosOfAt = email.indexOf("@")
    var lPosOfAt = email.lastIndexOf("@")
    var fPosOfDot = email.indexOf(".")
    var lPosOfDot = email.lastIndexOf(".")
    if(fPosOfAt == "-1" || fPosOfAt == null || fPosOfDot == "-1" ||
    fPosOfDot == null || fPosOfAt != lPosOfAt || fPosOfDot != lPosOfDot ||
    fPosOfAt == 0 || fPosOfAt == email.length-1 || fPosOfDot == 0 ||
    fPosOfDot == email.length-1 || fPosOfAt > fPosOfDot || fPosOfDot ==
    fPosOfAt+1)
    {
    alert("Enter a valid E Mail address")
    return false
    }

    if((register.UserId.value.length < 8) ||
    (register.Password.value.length < 8))
    {
    alert("Both UserId and Password should be of minimum 8 characters
    each.")
    return false
    }

    var notAllowed = "~!@#$%^&*()-=+[]{}\|;:,<>./? "
    var uid = register.UserId.value
    var pword = register.Password.value
    var pword1 = register.rpasswd.value
    for(i = 0; i<notAllowed.length; i++)
    {
    badChar = notAllowed.charAt(i)
    if (uid.indexOf(badChar) != -1)
    {
    alert("The character " + badChar + " is not allowed in User Id")
    return false
    }
    }
    for(i = 0; i<notAllowed.length; i++)
    {
    badChar = notAllowed.charAt(i)
    if (pword.indexOf(badChar) != - 1)
    {
    alert("The character " + badChar + " is not allowed in
    Password")
    return false
    }
    }
    if(pword != pword1)
    {
    alert("Both the passwords should exactly match")
    return false
    }
    return true
    }
    </script>
    <body background = "http://matrix.csis.pace.edu/~f03-cs631r-s02/ProjectImages/bg2.jpg"
    leftmargin = "95">
    <img src= "http://matrix.csis.pace.edu/~f03-cs631r-s02/ProjectImages/tele2.jpg"
    hspace = "115" align = "left">
    <Form name = "search" method = "post" action =
    "http://matrix.csis.pace.edu/~f03-cs631r-s02/ProjectHtmls/prodsearch.html"
    onSubmit = "return validateform(this)">
    <select name = "product" size = "1">
    <option value = "Select" selected = "selected">Select</option>
    <option value = "Australia" >Australia</option>
    <option value = "Canada" >Canada</option>
    <option value = "China" >China</option>
    <option value = "Denmark" >Denmark</option>
    <option value = "England" >England</option>
    <option value = "Finland" >Finland</option>
    <option value = "Holland" >Holland</option>
    <option value = "India" >India</option>
    <option value = "Israel" >Israel</option>
    <option value = "New Zealand" >New Zealand</option>
    <option value = "Nigeria" >Nigeria</option>
    <option value = "Poland" >Poland</option>
    <option value = "Russia" >Russia</option>
    <option value = "South Africa" >South Africa</option>
    <option value = "Singapore" >Singapore</option>
    </select><br>
    <input type = "submit" name = "Submit" value = "Card Search">
    </form>
    <br>
    <a href = "http://matrix.csis.pace.edu/~f03-cs631r-s02/index.html"><img
    src = "http://matrix.csis.pace.edu/~f03-cs631r-s02/ProjectImages/home.gif"
    hspace="1"></a><a href="http://matrix.csis.pace.edu/~f03-cs631r-s02/ProjectHtmls/aboutus.html"><img
    src="http://matrix.csis.pace.edu/~f03-cs631r-s02/ProjectImages/aboutus.gif"
    hspace="1"></a><a href="http://matrix.csis.pace.edu/~f03-cs631r-s02/ProjectHtmls/products.html"><img
    src="http://matrix.csis.pace.edu/~f03-cs631r-s02/ProjectImages/products.gif"
    hspace="1"></a><a href="http://matrix.csis.pace.edu/~f03-cs631r-s02/ProjectHtmls/register.html"><img
    src="http://matrix.csis.pace.edu/~f03-cs631r-s02/ProjectImages/register.gif"
    hspace = "1"></a><a href="http://matrix.csis.pace.edu/~f03-cs631r-s02/ProjectHtmls/cart.html"><img
    src="http://matrix.csis.pace.edu/~f03-cs631r-s02/ProjectImages/cart.gif"
    hspace="1"></a><a href="mailto:"><img
    src="http://matrix.csis.pace.edu/~f03-cs631r-s02/ProjectImages/contactus.gif"
    hspace="1"></a><a href="http://matrix.csis.pace.edu/~f03-cs631r-s02/ProjectHtmls/login.html"><img
    src="http://matrix.csis.pace.edu/~f03-cs631r-s02/ProjectImages/login.gif"
    hspace="1"></a><br>
    <hr size = "3" color = "#000080" align = "left" width = "811" NOSHADE>
    <img src="http://matrix.csis.pace.edu/~f03-cs631r-s02/ProjectImages/register.gif"
    hspace = "350">
    <form name = "register" method = "POST" onSubmit = "return
    registerValidate()" action =
    "http://matrix.csis.pace.edu/~f03-cs631r-s02/cgi-bin/ProjectCGI/register.pl">
    <pre>
    <font size = "4" color = "navy"><b>
    First Name <input type = "text" Size ="30" name =
    "FirstName">
    Last Name <input type = "text" Size ="30" name =
    "LastName">
    Street Address1 <input type = "text" Size ="30"
    name = "StreetAddress1">
    Street Address2 <input type = "text" Size ="30"
    name = "StreetAddress2">
    City <input type = "text" Size ="30" name =
    "City">
    State <select name = "State" Size ="1">
    <option selected =
    "selected" value = "Select">Select</option>
    <option
    value="AL">Alabama</option>
    <option
    value="AK">Alaska</option>
    <option
    value="AZ">Arizona</option>
    <option
    value="AR">Arkansas</option>
    <option
    value="CA">California</option>
    <option
    value="CO">Colorado</option>
    <option
    value="CT">Connecticut</option>
    <option
    value="DE">Delaware</option>
    <option
    value="FL">Florida</option>
    <option
    value="GA">Georgia</option>
    <option
    value="HI">Hawaii</option>
    <option
    value="ID">Idaho</option>
    <option
    value="IL">Illinois</option>
    <option
    value="IN">Indiana</option>
    <option
    value="IA">Iowa</option>
    <option
    value="KS">Kansas</option>
    <option
    value="KY">Kentucky</option>
    <option
    value="LA">Louisiana</option>
    <option
    value="ME">Maine</option>
    <option
    value="MD">Maryland</option>
    <option
    value="MA">Massachusetts</option>
    <option
    value="MI">Michigan</option>
    <option
    value="MN">Minnesota</option>
    <option
    value="MS">Mississippi</option>
    <option
    value="MO">Missouri</option>
    <option
    value="MT">Montana</option>
    <option
    value="NE">Nebraska</option>
    <option
    value="NV">Nevada</option>
    <option value="NH">New
    Hampshire</option>
    <option value="NJ">New
    Jersey</option>
    <option value="NM">New
    Mexico</option>
    <option value="NY">New
    York</option>
    <option value="NC">North
    Carolina</option>
    <option value="ND">North
    Dakota</option>
    <option value="OH">Ohio</option>
    <option
    value="OK">Oklahoma</option>
    <option
    value="OR">Oregon</option>
    <option
    value="PA">Pennsylvania</option>
    <option value="RI">Rhode
    Island</option>
    <option value="SC">South
    Carolina</option>
    <option value="SD">South
    Dakota</option>
    <option
    value="TN">Tennessee</option>
    <option
    value="TX">Texas</option>
    <option
    value="UT">Utah</option>
    <option
    value="VT">Vermont</option>
    <option
    value="VA">Virginia</option>
    <option
    value="WA">Washington</option>
    <option value="WV">West
    Virginia</option>
    <option
    value="WI">Wisconsin</option>
    <option
    value="WY">Wyoming</option>
    </select>
    zip <input type = "text" Size ="5" name = "Zip">
    E-Mail <input type = "text" Size ="30" name =
    "Email">
    <br>
    Please select your user id and password
    User Id <input type = "text" Size ="30" name =
    "UserId">
    Password <input type = "password" Size ="30" name
    = "Password">
    Re-enter Password <input type = "password" Size
    ="30" name = "rpasswd"><br>
    <input type = "reset" name = "reset" value = "Reset">
    <input type = "Submit" name = "submit" value = "Submit">
    </b> </font>
    </pre>
    </form>
    </body>
    </html>

    Please advise as to how to rectify this error.

    Kannan.
     
    G Kannan, Oct 11, 2003
    #1
    1. Advertising

  2. -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    (G Kannan) wrote in
    news::

    > Hey all!
    >
    > I have written a perl script to retrieve information from a HTML Form
    > and insert the data into an Oracle database table. I am gettting the
    > the following error message:
    >
    > "Use of uninitialized value in concatenation (.) at register.pl line
    > 38, <STDIN> line 10."
    >
    > The PERL code is as follows:
    >
    > #!/usr/bin/perl -w
    > $| = 1;
    > use strict;
    > use DBI;
    > use CGI qw:)standard);
    >
    > my $name1 = "";
    > my $name2 = "";
    > my $strt1 = "";
    > my $strt2 = "";
    > my $cityname = "";
    > my $statename = "";
    > my $zipcode = "";
    > my $emailadd = "";
    > my $useridname = "";
    > my $passwd = "";
    > my $query = "";
    > my $queh = "";
    > my $queout = "";
    > my $rec = "";
    > my $table ="";
    > my $query1 = "";
    > my $ques = "";
    >
    > $name1 = param("FirstName");
    > $name2 = param("LastName");
    > $strt1 = param("StreetAddress1");
    > $strt2 = param("StreetAddress2");
    > $cityname = param("City");
    > $statename = param("State");
    > $zipcode = param("Zip");
    > $emailadd = param("Email");
    > $useridname = param("UserId");
    > $passwd = param("Password");
    >
    > my $dbh =
    > DBI->connect('DBI:Oracle:host=172.17.28.199;sid=ORA1','f03-cs631r-s02',
    > 'architecture') or die "Connection to DB could not be made:",
    > $ques->errstr, "\n"; $query = qq[select * from customer_info where
    > userid = $useridname]; $queh = $dbh->prepare($query)
    > or die "Select statement could not be prepared:", $queh->errstr,
    > "\n";
    > $queout = $queh->execute()
    > or die "Select statement could not be executed: ", $queout->errstr,
    > "\n";
    > print header();
    > if ($queout){


    [snip 450 lines of irrelevant code]

    Did you really have to post your whole damn program? Couldn't you just
    have posted the code up to line 38 and be done with it? Also, would it
    have killed you to point out which line is line 38, instead of making
    everyone who might want to help you count the lines by hand?

    > Please advise as to how to rectify this error.


    Here's your warning message (note that it is not an error message):

    > "Use of uninitialized value in concatenation (.) at register.pl line
    > 38, <STDIN> line 10."


    Here's line 38, if I've counted correctly:

    > $query = qq[select * from customer_info where userid = $useridname];


    Variable interpolation ($useridname within the qq[] string) is a special
    case of concatenation. Clearly, $useridname is undefined.

    Here is the only place I can see where $useridname is assigned:

    > $useridname = param("UserId");


    Clearly, param() is returning undef. If you bother to read the CGI
    documentation, you'll see that this happens when there is no "UserID"
    parameter in the CGI request.


    These are simple, obvious steps in diagnosing the problem. None of these
    steps is difficult -- even for a rank beginner. If you lack the
    initiative to look up error messages in the documentation that came with
    your Perl distribution, or to read the CGI documentation, there's not
    much I or anyone else can do to help.

    It really looks like you just dumped your entire program onto a newsgroup
    and cried "help!" at the first sign of any problems. Don't expect
    further help unless you can show that you are actually trying to solve
    the problem yourself or are trying to learn.

    - --
    Eric
    $_ = reverse sort $ /. r , qw p ekca lre uJ reh
    ts p , map $ _. $ " , qw e p h tona e and print

    -----BEGIN PGP SIGNATURE-----
    Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

    iQA/AwUBP4fwYmPeouIeTNHoEQJdxACfSJ3TBRsnnE/ERfUrvRqayliBZB4AnAx+
    who1CTiTa0J7YmTOvqi2VOd3
    =Z3tJ
    -----END PGP SIGNATURE-----
     
    Eric J. Roode, Oct 11, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sukhbir Dhillon
    Replies:
    1
    Views:
    6,300
    Joe Smith
    Apr 5, 2004
  2. smartins68
    Replies:
    1
    Views:
    6,070
    Joe Smith
    Jun 9, 2004
  3. S
    Replies:
    3
    Views:
    361
    Gunnar Hjalmarsson
    Feb 3, 2004
  4. Jesse Cary
    Replies:
    2
    Views:
    234
    J├╝rgen Exner
    Oct 15, 2004
  5. Amaninder
    Replies:
    6
    Views:
    247
    J. Gleixner
    Jul 18, 2006
Loading...

Share This Page