in reply to Re: cannot retrieve value from select statement
in thread cannot retrieve value from select statement

Actually, I suspect that $dbh->do() succeeded :-). The problem is that do() doesn't ever return an $sth. Good point about error checking though. I'd recommend setting RaiseError in the connect rather than adding it to each statement.

update I should add this to the "mistakes I make far too often" thread as I've also mistakenly used do() instead of prepare(). do() is for instructions; prepare() is for requests that return data. do() returns the number of rows impacted; prepare() returns a statement handle that can be used to fetch data and metadata.

  • Comment on Re^2: cannot retrieve value from select statement

Replies are listed 'Best First'.
Re^3: cannot retrieve value from select statement
by davido (Cardinal) on Apr 05, 2005 at 05:56 UTC

    Good point. And yes, I fell into the same manner of thinking that you identified in your update. :) Ok, either way, he's not getting a valid statement handle (whether its due to silent failure, or because do() never returns a statement handle in the first place). And that's why when he attempts to use $sth2->fetchrow_array() he's getting the error message. $sth2 will never contain a statement handle, and thus, fetchfow_array() will never be a method of $sth2.


    Dave