See inline comment.
Soheil Shaghaghi wrote:
> Hi everyone,
> Can anyone please tell me what the problem is with this code?
> Every time I run my program with this code in it, I get an error in the log
> files:
> DBD::mysql::st fetchrow_array failed: fetch() without execute() at
> IWeb/sqlengine.pm line 3395.
>
>
>
> sub SQL_Is_Sponsor {
> my ($link_id) = @_;
> my $is_sponsor = 0;
>
> if($link_id) {
> my $PriviledgeGroupID;
> $SQL = "SELECT account FROM HS_links WHERE id = $link_id";
> $sth = $dbh->prepare($SQL) || IWEB::SQL_ERROR($SQL);
> $rc = $sth->execute || IWEB::SQL_ERROR($SQL);
>
> my($account) = $sth->fetchrow_array;
>
> if($account) {
> $SQL = "SELECT PriviledgeGroupID FROM USERU WHERE UserName =
> '$account'";
> $sth = $dbh_bac->prepare($SQL) || IWEB::SQL_ERROR($SQL);
> $PriviledgeGroupID = $sth->fetchrow_array;
-----> Right here you have prepared a new statement and reused your
statement handle variable ($sth), which you then call fetchrow_array on
without doing the actual execute first.
Sidenote: Either you should not clobber your statement handle variable
(so that it can be reused later) or you might consider using a "join" so
that you only have to do one select.
http://danconia.org
<snip>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]