Hello again monks! With regards to my last problem, I some how solved it....it kind of has a bug vbut as long as those witty end-users read before they do (yeah right) it should be fine! Anyway a new day dawns a new problem...... This one is to do with our good friend GREP. The code is as follows......
#!C:\strawberry\perl\bin\perl.exe use dbi; $usernameentered = "user89"; $passwordentered = "password12"; $dbh = DBI->connect('dbi:mysql:Database','username','password') or die "Connection Error: $DBI::errstr\n"; $sql = "select * from usertable"; $sth = $dbh->prepare($sql); $sth->execute or die "SQL Error: $DBI::errstr\n"; while (@row = $sth->fetchrow_array) { @username= grep /$usernameentered/, @row; print "@username\n"; @password= grep /$passwordentered/, @row; print "@password\n"; if (@username !=$usernameentered) { print "incorrect username entered @username\n"; } if (@password !=$passwordentered) { print "incorrect password entered @password\n"; } }
Now as you may or may not be able to tell this aims to match the output from the database (in the @row) with the input from $usernameentered and $passwordentered.....and yes it kind of works......when run it returns user89 password12 but then it says......... incorrect username entered user89 incorrect password entered password12 These arent incorrect, they match just fine with whats in the database and the corresponding password. So whats gone wrong now masters, if only I could go a day without running into such errors.......it would be dreamy! OK I WANT THE PASSWORD ENTERED AND USERNAME ENTERED TO DISPLAY LIKE THEY ARE! HOWEVER I WANT TO GET IT SO THE INCORRECT.....BITS DONT DISPLAY AS I DONT THINK THEY SHOULD BE THERE.......MY QUESTION BEING HOW CAN I GET RID OF THIS AND SOLVE THIS BUG IN MY CODE? See a question now :-D bogglemaster89 bogglemaster89

In reply to perl grep help! by bogglemaster89

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.