unknown error

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
mad_phpq
Forum Commoner
Posts: 85
Joined: Fri Apr 27, 2007 5:53 am

unknown error

Post by mad_phpq »

Warning: mysqli::prepare() [function.mysqli-prepare]: All data must be fetched before a new statement prepare takes place in menu.class.php on line 185

Code: Select all

function GetByParent ( $parent_id, $menu_id )
		{
		
			global $mysqli;
			
			var_dump($menu_id);
			
LINE 185	                $stmt = $mysqli->prepare("call menu_itemsGetByParen_proc(?)");
			$stmt->bind_param("ii", $parent_id, $menu_id);
			$stmt->execute();			

			$aRet = array();
			
			while ( $row = $stmt->fetch() ){
				$clObject = new menu_itemsInfo ( $row["id"], $row["menu_id"], $row["parent_id"], $row["menu_item_name"], $row["url"], $row["accesskey"] );
				array_push ( $aRet, $clObject );
			}
		
			$stmt->close();
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You haven't read all the result data.
mad_phpq
Forum Commoner
Posts: 85
Joined: Fri Apr 27, 2007 5:53 am

Post by mad_phpq »

would you know why it hasnt. Is there a function i can use to clear the data.... or do i have to open a different connection?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

You probably have another (prepared) statement in your script that is still active (and has unread data) when GetByParent is called.
And yes, there is a function to clear the data, http://de2.php.net/manual/en/function.m ... -close.php
You're already using it for the statement in GetbyParent, $stmt->close()
mad_phpq
Forum Commoner
Posts: 85
Joined: Fri Apr 27, 2007 5:53 am

Post by mad_phpq »

i have a stmt->close() in every function.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

There is a chance that it is not closed prior to this function call, as $mysqli is globalized.
mad_phpq
Forum Commoner
Posts: 85
Joined: Fri Apr 27, 2007 5:53 am

Post by mad_phpq »

ok. thanks. I think i'll have to go back to the drawing board then. Thanks for your help.

While, i'm here, does anyone know any good php/mysql stored procedures code samples?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

What is the procedure trying to do? I have a few, but like PHP, it is better to know what you want done that to throw out guesses without knowing.
Post Reply