Page 1 of 1

PROCEDURE can't return a result set in the giv

Posted: Thu Oct 21, 2010 8:39 am
by sunegtheoverlord
Hello,

I'm new to PHP and MYSQL.

Have just set up XAMPP for windows and have written a basic web page to connect to MYSQL and run a stored procedure but i keep getting this error "PROCEDURE htc.get_bands can't return a result set in the given context".

The procedure is a simple SELECT * statement. If i actually write the statement into the php code it works. But when i CALL the stored procedure to do the same thing i get the error.

I've had a look on google but theres alot of posts on this and some seem to be bugs but i'm using PHP 5.3.1 and latest version on XAMPP.

Any ideas?

Code: Select all

<?php
include("connect.php");


$query = "CALL get_bands;";

$result = mysql_query($query) or die("Query failed with error: ".mysql_error());


while($row = mysql_fetch_array($result))
  {
  echo $row['BandRef'] . " " . $row['BandName];
  echo "<br />";
  }

mysql_close($con);
?> 

Re: PROCEDURE can't return a result set in the giv

Posted: Thu Oct 21, 2010 9:54 am
by VladSun

Re: PROCEDURE can't return a result set in the giv

Posted: Thu Oct 21, 2010 3:12 pm
by sunegtheoverlord
Hi Vlad,

Thanks for the reply.

so i have to set the CLIENT_MULTI_RESULTS flag.

How exactly do i do that though? in my php code? in MySQL?

Please spell it out for me as i'm very new to this!

S

Re: PROCEDURE can't return a result set in the giv

Posted: Thu Oct 21, 2010 3:16 pm
by VladSun
User comments in PHP manual regarding mysql_connect suggest that:

Code: Select all

mysql_connect($host, $user, $pass, false, 65536);
And the manual says:
http://www.php.net/manual/en/mysql.cons ... ient-flags

i.e.
65536 == CLIENT_MULTI_STATEMENTS

Re: PROCEDURE can't return a result set in the giv

Posted: Fri Oct 22, 2010 7:08 am
by sunegtheoverlord
Hi Vlad,

Still the same error message returned. I have updated my connect.php code as you said (below)

What now?

Code: Select all

<?php

$con = mysql_connect("localhost","crewmember2", "", false, 65536) or exit( mysql_error() );
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
 

mysql_select_db("HTC", $con);

?>