I get error "PROCEDURE xxx can't return a result set in the given context" when I call php script

I got php script to get results from MySql prosedure (view). When i call prosedure from MySql server it's working, but PHP script give me error:  "PROCEDURE xxx can't return a result set in the given context". PHP script working with select queries (view). When prosedure return that same view to the script it's not working.

What's wrong with the PHP-script. Any comments would be great.

Mircci

Prosedure:
CREATE DEFINER=`kulmakonditoria`@`%` PROCEDURE `Kirjaudu`(Tunnus VARCHAR(50),Salasana VARCHAR(50))
BEGIN
 
SELECT Nimi FROM Tekijat
WHERE Tekijat.Tunnus = Tunnus AND Tekijat.Salasana=Salasana;
 
END
_____________________________________________________
PHP::
<?php
header('Content-type: application/octet-stream');
$runSQL = true;	
error_reporting(0);
$value="<flashsql>";
 
if($runSQL){
	if (!mysql_connect($_POST['host'], $_POST['uname'], $_POST['pword'])) {
		//Could not connect to database
		$value.=" <database_connection>0</database_connection>\n";
		$value.=" <error>".utf8_encode(mysql_error())." </error>\n";
	}else{
		$value.=" <database_connection>1</database_connection>\n";
		if(!mysql_select_db($_POST['dat'])){
			//Connected to database but cannot select database
			$value.=" <database_selection>0</database_selection>\n";
			$value.=" <error>".utf8_encode(mysql_error())." </error>\n";
		}else{
			//Connected to and selected database
			$value.=" <database_selection>1</database_selection>\n";
			$qry_val = iconv("UTF-8", "ISO-8859-1", stripcslashes($_POST['query']));
			if(!$result = mysql_query($qry_val)){
				$value.=" <sql>0</sql>\n"; //sql failed to run
				$value.=" <error>".utf8_encode(mysql_error())." </error>\n";
			}else{
				$value.=" <sql>1</sql>\n"; //sql ran well
				$value.=" <results>\n";
					$num_cols = mysql_num_fields($result);
					$count = 1;
					while ($row = mysql_fetch_row($result)){
						$value.="<record>\n<count>".$count."</count>\n";
						for($i=0; $i<$num_cols; $i++){
							$vals = "<".mysql_field_name($result,$i)."> <![CDATA[".$row[$i]."]]></".mysql_field_name($result,$i).">";
							$value.=$vals;
						}
						$value.="</record>";
						$count++;
					}
				
				$value.=" </results>\n";
			}
		}
	}
}
$value.="</flashsql>";
//print $value;
print gzcompress($value);
?>

Open in new window

MircciAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NoiSCommented:
Are you trying to execute an Stored Procedure?
The mysql extension don't work with Stored Procedure;

Try changing to mysqli, PDO, ADODB, etc;

0
MircciAuthor Commented:
I'm calling procedure (CALL kulmakonditoria.Kirjaudu('Mirka','joku')) from Flex (as3) application. PHP Script working with that, only results from procedure (view) it's not working.
0
NoiSCommented:
So.. the mysql extension don't have the ability to retrieve data from cursors.

You must use another extensions.
See in your phpinfo(); what extension you have. If you have mysqli use it. Is almos the same code thar mysql extension.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MircciAuthor Commented:
Two hours and I got it, heh. Thank you very much!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.