Sorry about being to vague, I want to search my database to see if the
information that was entered already exists in there. I check by a field
called username. When I do the SELECT statement on the table I am checking
it returns a row count of -2. I am baffled.
----- Original Message -----
From: "Gerald L. Clark" <gerald_clark@stripped>
To: "Mike Podlesny" <m.podlesny@stripped>
Cc: "mySQL Mailing List" <mysql@stripped>
Sent: Friday, December 29, 2000 10:42 AM
Subject: Re: HELP!!!
> Mike Podlesny wrote:
> >
> > I am trying to access the mySQL database using PERL and am trying to do
an
> > if statement after executing a SELECT query. It looks like this: CAN
> > ANYONE HELP ME...PLEASE!!
> >
> > -------------------------------------------------------------------
> > # We check to see if the user already exists
> > $sth = $dbh->prepare("SELECT COUNT(*) FROM Customers WHERE
> > Customer_Name=$fields{'username'}");
> > $sth->execute();
> >
> > $rv = $sth->rows;
> >
> > if ($rv > 0) {print "<font color=blue>The </font><font
> color=red>USER
> > NAME</font> <font color=blue>that you have entered has already been
> > taken.</font>\n\n";}
> > else
> > {
> > $sth = $dbh->prepare("INSERT INTO Customers
> >
(Customer_Name,Customer_PWD,fullname,address,email,city,state,zipcode,q1,q2,
> > q3,q4,q5,q6,q7) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
> >
$sth->execute($fields{'username'},$fields{'password'},$fields{'fullname'},$f
> >
ields{'address'},$fields{'email'},$fields{'city'},$fields{'state'},$fields{'
> >
zipcode'},$fields{'q1'},$fields{'q2'},$fields{'q3'},$fields{'q4'},$fields{'q
> > 5'},$fields{'q6'},$fields{'q7'});
> >
> > print "<font color=blue><h1>Congratulations!
> > $fields{'fullname'}</h1></font>\n";
> > print "<font color=blue><br>You are now registered to use
> > IWantYourStuff.com</font>\n";
> > }
> > $sth->finish;
> > $dbh->disconnect;
> >
> 1. You never executed the prepared statement in the else clause.
> 2. You did not state your problem.