Page 1 of 1

PHP with MySQLi help!

Posted: Tue Aug 10, 2010 11:40 pm
by kevinevans
So, I'm having a problem with MySQLi, more specifically:

Code: Select all

Warning: mysqli::prepare() [mysqli.prepare]: All data must be fetched before a new statement prepare takes place in E:\xampp\nothing\inc\classes.php on line 489
Essentially, I have some queries that have a pseudocode like:

Code: Select all

if ( $st = $mysqli->prepare( "SELECT ...") )
{
   $st->bind_param( ... );
   $st->execute();
   $st->bind_result( $result );
   while( $st->fetch() )
   {
      $p = new Post( $result );
      $p->display();
   }
   $st->close();
}

// Then display looks something like:
var $result;
function display()
{
   echo "The result is: " . $this->result;
   // The error is coming from this line:
   if ( $st = $mysqli->prepare( ... ) )
   {
      $st->bind_param( ... );
      $st->execute();
      $st->bind_result( ... );
      echo "something";
      $st->close();
   }
}
I'm pretty sure it's because i have a query while another query is still there (and not all fetched). Is there anyway that I could fix this?

<3
Thankies

Re: PHP with MySQLi help!

Posted: Wed Aug 11, 2010 1:38 am
by novito
Hi there,

I would say that you need to read all the results before executing another query. I think the function "store_result" might help if you can't do all the queries you want in a join.

I hope this helps :]