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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • G Kannan

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

    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("FirstNam e");
    $name2 = param("LastName ");
    $strt1 = param("StreetAd dress1");
    $strt2 = param("StreetAd dress2");
    $cityname = param("City");
    $statename = param("State");
    $zipcode = param("Zip");
    $emailadd = param("Email");
    $useridname = param("UserId") ;
    $passwd = param("Password ");

    my $dbh = DBI->connect('DBI:O racle:host=172. 17.28.199;sid=O RA1','f03-cs631r-s02','architect ure')
    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><t itle>User Id already taken</title></head>";
    print "<script language=\"java script\">";
    print "function validateform(fo rm)";
    print "{";
    print "if (form.product.v alue == \"Select\")" ;
    print "{";
    print "alert(\"Se lect a country to search...\")";
    print "return false";
    print "}";
    print "return true";
    print "}";
    print "</script>";
    print "<body>";
    print "<body background = \"ProjectIma ges/bg2.jpg\" leftmargin =
    \"95\">";
    print "<img src= \"ProjectIma ges/tele2.jpg\" hspace = \"115\" align
    = \"left\">";
    print "<Form name = \"search\" method = \"post\" action =
    \"ProjectHtm ls/prodsearch.html \" onSubmit = \"return
    validateform(th is)\">";
    print "<select name = \"product\" size = \"1\">";
    print "<option value = \"Select\" selected =
    \"selected\">Se lect</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 =
    \"ProjectIma ges/home.gif\" hspace=\"1\"></a><a
    href=\"ProjectH tmls/aboutus.html\"> <img
    src=\"ProjectIm ages/aboutus.gif\" hspace=\"1\"></a><a
    href=\"ProjectH tmls/products.html\" ><img
    src=\"ProjectIm ages/products.gif\" hspace=\"1\"></a><a
    href=\"ProjectH tmls/register.html\" ><img
    src=\"ProjectIm ages/register.gif\" hspace = \"1\"></a><a
    href=\"ProjectH tmls/cart.html\"><im g src=\"ProjectIm ages/cart.gif\"
    hspace=\"1\"></a><a href=\"mailto:K annan.Govindara jan\@pace.edu\" ><img
    src=\"ProjectIm ages/contactus.gif\" hspace=\"1\"></a><a
    href=\"ProjectH tmls/login.html\"><i mg src=\"ProjectIm ages/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 = \"ProjectHtm ls/register.html\" >Back to
    Registration Page</a>";
    print "</font>";
    print "</body>";
    print "</html>";
    }
    else {
    $table = "customer_info" ;
    $query1 = "INSERT INTO " . $table .
    "VALUES('.$name 1.','.$name2.', '.$strt1.','.$s trt2.','.$cityn ame.','.$staten ame.','.$zipcod e.','.$emailadd .','.$useridnam e.','.$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(fo rm)------------------------------------------------
    function validateform(fo rm)
    {
    if (form.product.v alue == "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
    registerValidat e()------------------------------------------------
    function registerValidat e()
    {
    for(i=0; i<register.elem ents.length; i++)
    {
    if((register.el ements[i].value == "") ||
    (register.eleme nts[i].value == null))
    {
    if(i==3)
    continue
    alert("Please fill the field " + register.elemen ts[i].name +
    ".")
    return false
    }
    }

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

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

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

    if(register.Sta te.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.va lue
    if(!(isNumber(z ip1)))
    {
    alert("The Zip code should be only numbers")
    return false
    }

    var email = register.Email. value
    var fPosOfAt = email.indexOf(" @")
    var lPosOfAt = email.lastIndex Of("@")
    var fPosOfDot = email.indexOf(" .")
    var lPosOfDot = email.lastIndex Of(".")
    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.Us erId.value.leng th < 8) ||
    (register.Passw ord.value.lengt h < 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.Passwo rd.value
    var pword1 = register.rpassw d.value
    for(i = 0; i<notAllowed.le ngth; i++)
    {
    badChar = notAllowed.char At(i)
    if (uid.indexOf(ba dChar) != -1)
    {
    alert("The character " + badChar + " is not allowed in User Id")
    return false
    }
    }
    for(i = 0; i<notAllowed.le ngth; i++)
    {
    badChar = notAllowed.char At(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.pac e.edu/~f03-cs631r-s02/ProjectImages/bg2.jpg"
    leftmargin = "95">
    <img src= "http://matrix.csis.pac e.edu/~f03-cs631r-s02/ProjectImages/tele2.jpg"
    hspace = "115" align = "left">
    <Form name = "search" method = "post" action =
    "http://matrix.csis.pac e.edu/~f03-cs631r-s02/ProjectHtmls/prodsearch.html "
    onSubmit = "return validateform(th is)">
    <select name = "product" size = "1">
    <option value = "Select" selected = "selected">Sele ct</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.pac e.edu/~f03-cs631r-s02/index.html"><im g
    src = "http://matrix.csis.pac e.edu/~f03-cs631r-s02/ProjectImages/home.gif"
    hspace="1"></a><a href="http://matrix.csis.pac e.edu/~f03-cs631r-s02/ProjectHtmls/aboutus.html">< img
    src="http://matrix.csis.pac e.edu/~f03-cs631r-s02/ProjectImages/aboutus.gif"
    hspace="1"></a><a href="http://matrix.csis.pac e.edu/~f03-cs631r-s02/ProjectHtmls/products.html"> <img
    src="http://matrix.csis.pac e.edu/~f03-cs631r-s02/ProjectImages/products.gif"
    hspace="1"></a><a href="http://matrix.csis.pac e.edu/~f03-cs631r-s02/ProjectHtmls/register.html"> <img
    src="http://matrix.csis.pac e.edu/~f03-cs631r-s02/ProjectImages/register.gif"
    hspace = "1"></a><a href="http://matrix.csis.pac e.edu/~f03-cs631r-s02/ProjectHtmls/cart.html"><img
    src="http://matrix.csis.pac e.edu/~f03-cs631r-s02/ProjectImages/cart.gif"
    hspace="1"></a><a href="mailto:Ka nnan.Govindaraj an@pace.edu"><i mg
    src="http://matrix.csis.pac e.edu/~f03-cs631r-s02/ProjectImages/contactus.gif"
    hspace="1"></a><a href="http://matrix.csis.pac e.edu/~f03-cs631r-s02/ProjectHtmls/login.html"><im g
    src="http://matrix.csis.pac e.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.pac e.edu/~f03-cs631r-s02/ProjectImages/register.gif"
    hspace = "350">
    <form name = "register" method = "POST" onSubmit = "return
    registerValidat e()" action =
    "http://matrix.csis.pac e.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">Alab ama</option>
    <option
    value="AK">Alas ka</option>
    <option
    value="AZ">Ariz ona</option>
    <option
    value="AR">Arka nsas</option>
    <option
    value="CA">Cali fornia</option>
    <option
    value="CO">Colo rado</option>
    <option
    value="CT">Conn ecticut</option>
    <option
    value="DE">Dela ware</option>
    <option
    value="FL">Flor ida</option>
    <option
    value="GA">Geor gia</option>
    <option
    value="HI">Hawa ii</option>
    <option
    value="ID">Idah o</option>
    <option
    value="IL">Illi nois</option>
    <option
    value="IN">Indi ana</option>
    <option
    value="IA">Iowa </option>
    <option
    value="KS">Kans as</option>
    <option
    value="KY">Kent ucky</option>
    <option
    value="LA">Loui siana</option>
    <option
    value="ME">Main e</option>
    <option
    value="MD">Mary land</option>
    <option
    value="MA">Mass achusetts</option>
    <option
    value="MI">Mich igan</option>
    <option
    value="MN">Minn esota</option>
    <option
    value="MS">Miss issippi</option>
    <option
    value="MO">Miss ouri</option>
    <option
    value="MT">Mont ana</option>
    <option
    value="NE">Nebr aska</option>
    <option
    value="NV">Neva da</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">Nort h
    Carolina</option>
    <option value="ND">Nort h
    Dakota</option>
    <option value="OH">Ohio </option>
    <option
    value="OK">Okla homa</option>
    <option
    value="OR">Oreg on</option>
    <option
    value="PA">Penn sylvania</option>
    <option value="RI">Rhod e
    Island</option>
    <option value="SC">Sout h
    Carolina</option>
    <option value="SD">Sout h
    Dakota</option>
    <option
    value="TN">Tenn essee</option>
    <option
    value="TX">Texa s</option>
    <option
    value="UT">Utah </option>
    <option
    value="VT">Verm ont</option>
    <option
    value="VA">Virg inia</option>
    <option
    value="WA">Wash ington</option>
    <option value="WV">West
    Virginia</option>
    <option
    value="WI">Wisc onsin</option>
    <option
    value="WY">Wyom ing</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.
  • Eric J. Roode

    #2
    Re: Use of uninitialized value in concatenation (.) at register.pl line 38, &lt;STDIN&gt ; line 10.

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

    gkannan65@yahoo .com (G Kannan) wrote in
    news:4a2c62fc.0 310101645.5a376 3dd@posting.goo gle.com:
    [color=blue]
    > 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("FirstNam e");
    > $name2 = param("LastName ");
    > $strt1 = param("StreetAd dress1");
    > $strt2 = param("StreetAd dress2");
    > $cityname = param("City");
    > $statename = param("State");
    > $zipcode = param("Zip");
    > $emailadd = param("Email");
    > $useridname = param("UserId") ;
    > $passwd = param("Password ");
    >
    > my $dbh =
    > DBI->connect('DBI:O racle:host=172. 17.28.199;sid=O RA1','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){[/color]

    [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?
    [color=blue]
    > Please advise as to how to rectify this error.[/color]

    Here's your warning message (note that it is not an error message):
    [color=blue]
    > "Use of uninitialized value in concatenation (.) at register.pl line
    > 38, <STDIN> line 10."[/color]

    Here's line 38, if I've counted correctly:
    [color=blue]
    > $query = qq[select * from customer_info where userid = $useridname];[/color]

    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:
    [color=blue]
    > $useridname = param("UserId") ;[/color]

    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/AwUBP4fwYmPeouI eTNHoEQJdxACfSJ 3TBRsnnE/ERfUrvRqayliBZB 4AnAx+
    who1CTiTa0J7YmT Ovqi2VOd3
    =Z3tJ
    -----END PGP SIGNATURE-----

    Comment

    Working...