views:

17

answers:

1

$link = mysqli_connect("localhost", "username", "testpassword", "dbname")or die('connection problem');

/* check connection */ if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error()); exit(); }

//if ($result = mysqli_query($link, "CALL my_sqrt(Other,@out_value)")) {

$result = mysqli_query($link, "CALL show_sp_test()");

$row_cnt = mysqli_num_rows($result);

printf("Result set has %d rows.\n", $row_cnt);

/* close result set */
mysqli_free_result($result); //}

/* close connection */ mysqli_close($link);

I got error like

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in sample-sp.php on line 19
Result set has 0 rows.
Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in sample-sp.php on line 24

but i change the stored procedure CALL to normal query working fine,

Tell me , is there any thing i should check /,

Is there any Bug in my snippet,

NOTE: IN MY SERVER MYSQLI ENABLED

Thanks

A: 

Looks like you have an error in the query.

You are not checking the return value of mysqli_query which returns false if it fails. You can get the reason for failing by calling mysqli_error($link) as:

$result = mysqli_query($link, "CALL show_sp_test()");
if(!$result) {
    die('Invalid query: ' . mysqli_error($link));
}
codaddict
> Warning: mysqli_error() expects exactly 1 parameter, 0 given in /sample-sp.php on line 15Invalid query:
Bharanikumar
I've updated my ans.
codaddict
yes , but error , still there in , what step should i take, only sp query not execution.
Bharanikumar