PROCEDURE can't return a result set in the giv

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
User avatar
sunegtheoverlord
Forum Commoner
Posts: 28
Joined: Thu Feb 18, 2010 5:02 am

PROCEDURE can't return a result set in the giv

Post 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);
?> 
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

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

Post by VladSun »

There are 10 types of people in this world, those who understand binary and those who don't
User avatar
sunegtheoverlord
Forum Commoner
Posts: 28
Joined: Thu Feb 18, 2010 5:02 am

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

Post 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
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

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

Post 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
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
sunegtheoverlord
Forum Commoner
Posts: 28
Joined: Thu Feb 18, 2010 5:02 am

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

Post 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);

?> 
Post Reply