PHP with MySQLi help!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kevinevans
Forum Newbie
Posts: 1
Joined: Tue Aug 10, 2010 11:30 pm

PHP with MySQLi help!

Post 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
User avatar
novito
Forum Commoner
Posts: 26
Joined: Mon Apr 07, 2008 11:08 am

Re: PHP with MySQLi help!

Post 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 :]
Post Reply