---
title: "PROCEDURE can’t return a result set in the given context"
author: "phpseyo"
date: "2012-08-29T12:11:31Z"
tags: []
categories: ["编程语言"]
slug: "procedure-can-t-return-a-result-set-in-the-given-context"
draft: false
lastmod: "2012-08-29T12:11:31Z"
id: 1666589
url: "https://phpseyo.iteye.com/blog/1666589"
---

```
PROCEDURE db.procedure_name can't return a result set in the given context
```

Of course ‘db.procedure\_name’ was the actual name of the procedure I was calling. [Googling](http://www.google.com/search?q=can%27t%20return%20a%20result%20set%20in%20the%20given%20context) for the error seemed to indicate that the MySQL client library was old, but this is on a fairly modern CentOS 5.5 server with the php-mysql package at version 5.1.6.

After a bit of experimenting, I found that I was able to change to using the mysql improved versions of the PHP functions and that worked fine

```
     $dbconn = mysql_connect($dbhost, $dbuser, $dbpass);
     $result = mysql_query("CALL db.procedure_name('arg1', 'arg2', 'arg3')", $dbconn)
     $row    = mysql_fetch_assoc($result);
```

Becomes

```
    $dbconn = mysqli_connect($dbhost, $dbuser, $dbpass);
    $result = mysqli_query($dbconn, "CALLdb.procedure_name('arg1', 'arg2', 'arg3')");
    $row    = mysqli_fetch_assoc($result);
```