467,084 Members | 1,231 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,084 developers. It's quick & easy.

MySQLi - can't access stored procedure twice!


Running PHP v5.0.4 (compiled by www.entropy.ch) and mysql 5.0.16 on Mac
OS X 10.4.3. When I run the simple test script below the first query
sent from PHP to MySQL is successful but the second is not. sp_select is a
simple one-line script that performs "select * from test". If I replace
the call to the stored procedure with a select that does the same thing,
both queries work and return results. Is this a PHP or MySQL problem?
<html><body><pre><?php$query = "CALL sp_select()";//$query =
"select * from test"; $link = mysqli_connect("localhost", "root",
"xxxxx","test");var_dump($link);$result = mysqli_query($link,
$query);var_dump($result);$row =
mysqli_fetch_row($result);var_dump($row);mysqli_fr ee_result($result);var_dump($link);$result = mysqli_query($link,
$query);var_dump($result);$row
=
mysqli_fetch_row($result);var_dump($row);mysqli_fr ee_result($result);mysqli_close($link);?></pre></body></html>
------------------------------
Results when $query = "CALL sp_select()"; are below:

object(mysqli)#1 (0) {
}
object(mysqli_result)#2 (0) {
}
array(2) {
[0]=>
string(1) "1"
[1]=>
string(4) "greg"
}
object(mysqli)#1 (0) {
}
bool(false)

Warning: mysqli_fetch_row() expects parameter 1 to be mysqli_result,
boolean given in /Library/WebServer/Documents/sp/test.php on line 21
NULL

Warning: mysqli_free_result() expects parameter 1 to be mysqli_result,
boolean given in /Library/WebServer/Documents/sp/test.php on line 23
------------------------------
Results when $query = "select * from test"; are below:

object(mysqli)#1 (0) {
}
object(mysqli_result)#2 (0) {
}
array(2) {
[0]=>
string(1) "1"
[1]=>
string(4) "greg"
}
object(mysqli)#1 (0) {
}
object(mysqli_result)#3 (0) {
}
array(2) {
[0]=>
string(1) "1"
[1]=>
string(4) "greg"
}

Dec 5 '05 #1
  • viewed: 4352
Share:
2 Replies

A cleaner copy of the script (I hope)

<html><body><pre><?php$query = "CALL sp_select()";$query = "select
* from test"; $link = mysqli_connect("localhost", "root",
"gr8db","test");var_dump($link);$result = mysqli_query($link,
$query);var_dump($result);$row =
mysqli_fetch_row($result);var_dump($row);mysqli_fr ee_result($result);var_dump($link);$result = mysqli_query($link,
$query);var_dump($result);$row
=
mysqli_fetch_row($result);var_dump($row);mysqli_fr ee_result($result);mysqli_close($link);?></pre></body></html>
Dec 5 '05 #2

Third time is a charm...is is a copy of the test script with line
breaks:
<html>
<body>
<pre>
<?php>
$query = "CALL sp_select()";
//$query = "select * from test";

$link = mysqli_connect("localhost", "root","gr8db","test");

var_dump($link);
$result = mysqli_query($link,$query);
var_dump($result);
$row = mysqli_fetch_row($result);
var_dump($row);
mysqli_free_result($result);

var_dump($link);
$result = mysqli_query($link,$query);
var_dump($result);
$row = mysqli_fetch_row($result);
var_dump($row);
mysqli_free_result($result);

mysqli_close($link);
?>
</pre>
</body>
</html>
Dec 5 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by dumbledad@gmail.com | last post: by
1 post views Thread by evan.lavidor@gmail.com | last post: by
13 posts views Thread by Schmidty | last post: by
2 posts views Thread by Taras_96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.