Reply to MySQLi - can't access stored procedure twice!

Your name:

Reply:


Posted by Greg Schumacher on 12/06/05 02:02

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
asimple 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_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>

------------------------------
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"
}

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация