0

this is my code

$query="call call_history('','$real_sdate','$real_edate','$level','$userid',@_count,'0','10')";

 //Listing the result
 $rs = mysqli_query($mysqli,$query);
 
$rs = mysqli_query($mysqli,"SELECT @_count");
while($row = mysqli_fetch_assoc($rs))
{
print_r $row;
}

always i get blank result or error mysqli_fetch_assoc() expects parameter 1 to be mysqli_result

i want to do it with procedural mysqli.. not with oop mysqli..!!

Can anybody help.?

2
Contributors
8
Replies
13
Views
7 Years
Discussion Span
Last Post by nileshgr
0

as u clearly see that i m using call before call_history.. this show that its a store procedure..!!! and store procedure is working fine...

this store procedure has a out parameter..!!!
i just want to store that out parameter in an variable in php..!!

kindly tell me how to get out parameter in php

0

strange nobody knows how to get out parameter in php.. :O

0

i already tried tht link... but fail..!!
have u ever personally use that link..? :O

0

here you go dude. got this result after a lot of google work.

i create this procedure -

DELIMITER $$

DROP PROCEDURE IF EXISTS `test`.`p`$$
CREATE PROCEDURE `test`.`p` (out n INT)
BEGIN

SET n := 252;

END$$

DELIMITER ;

Now if i pass a param to the proccy, i should get 252 coz its out param.

<?php

$l = mysqli_connect('localhost', 'root', 'PAsSword', 'test');

$res = mysqli_query($l,"call p(@a);");

$res = mysqli_query($l, "select @a");

while($r = mysqli_fetch_array($res)) {
	
	var_dump($r);

}

and here's the output -

array(2) {
  [0]=>
  string(3) "252"
  ["@a"]=>
  string(3) "252"
}
0

Little change in your procedure -

DELIMITER $$

DROP PROCEDURE IF EXISTS `test`.`p`$$
CREATE PROCEDURE `p`(sid int,out n INT) # sid is IN parameter
BEGIN
select * from student where id = sid;  # test query
SET n := 252;
END$$

DELIMITER ;

PHP Code to get in as well as out parameter

<?php

$l = mysqli_connect('localhost', 'root', 'PAsSword', 'test');

$res = mysqli_query($l,"call p('1',@a);"); //1 is parameter

$res = mysqli_query($l, "select @a");

while($r = mysqli_fetch_array($res)) {
	
	var_dump($r);

}

i got the error..!!!

Commands out of sync; you can't run this command now

after little google i came our error..!!!
Thanks a lot..!!
:)

Edited by sam023: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.