|  | 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 MacOS 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"
 }
  Navigation: [Reply to this message] |