Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stored procedure is not working with PHP call [duplicate]

Possible Duplicate:
Can't return a result set in the given context

I am trying to call a basic stored procedure using PHP. But mysql produces an error like "PROCEDURE softland.getAllProducts can't return a result set in the given context".

Stored Procedure

 DELIMITER //
 CREATE PROCEDURE GetAllProducts()
 BEGIN
 SELECT *  FROM products;
 END //
 DELIMITER ;

PHP code is

<?php
$con=mysql_connect("localhost","root","");
mysql_select_db("softland",$con);
$id = 1;
$result = mysql_query("call getAllProducts()");
echo $result;

if ($result === FALSE) {
die(mysql_error());
}
while($row=mysql_fetch_array($result)){
    echo "<br>".$row['name'];
}
echo "Succees";
 ?>
like image 932
Sunil Avatar asked Dec 03 '25 06:12

Sunil


1 Answers

Well, this answer is straight from the php page on mysql_connect:

$this->con = mysql_connect($this->h,$this->u,$this->p,false,65536);

Which tells your mysql client to use multi-statement support (see also the mysql client constants: http://php.net/manual/en/mysql.constants.php#mysql.client-flags)

like image 63
mabi Avatar answered Dec 05 '25 21:12

mabi