I have a stored procedure in MySQL that is run from a PHP file. All is well so long as I comment out all cursor handling in the stored procedure (apart from the declarations).
If, however I leave so much as open myCursor;
running (with or without close myCursor;
) I get the error 'POST myphp.php net::ERR_CONNECTION_RESET'.
The definition of the cursor makes no difference. I've tried changing the cursor's select to something really simple that definitely runs.
Despite the error the processing done using the cursor works and the stored procedure continues logging its progress right to the end. It's only when it gets back to the PHP that it all falls to pieces for no apparent reason.
The only possibility that I can see is that the cursor corrupts the results, maybe by producing some warning message, but if so I don't know which message or how to deal with it and there's no obvious reason for an error message, particularly as I don't have to run so much as a single Fetch
on a cursor to produce the problem.
Here's how the stored procedure is run:
if ($stmt2 = mysqli_prepare($con, "call mySP(?)")) {#Store statement
mysqli_stmt_bind_param($stmt2, 's', $par);
mysqli_stmt_execute($stmt2);
$result = mysqli_stmt_get_result($stmt2);
mysqli_stmt_execute($stmt2);
is the last line that I can say for sure runs. Nothing in the rest of the PHP runs after $result = mysqli_stmt_get_result($stmt2);
.
Note that if after mysqli_stmt_execute($stmt2);
I output mysqli_stmt_errno($stmt2).','.mysqli_stmt_error($stmt2)
I get '0,' so it looks like there's no error being thrown by mysqli_stmt_execute($stmt2);
For completeness here's an excerpt from the javascript that's used to call the PHP:
$.ajax({
type : "POST",
url : "./php/myphp.php",
cache : false,
data : {
sheet : JSON.stringify(userJson)
},
datatype : "json"
}).done(function(result) {
Please help as I'm tearing my hair out over this and I can find no way to debug it or work around it.