i'm going nuts with a function that returns some values from a table, the code works, no mysql or php errors, but the array is not populated.
it's always returning a null value.
every attempt charles webproxy shows me that the result is null.
here is my code:
/**
* Returns the item corresponding to the value specified for the primary key.
*
* Add authorization or any logical checks for secure access to your data
*
* @param string $itemID
* @return stdClass[]
*/
public function getCursoInfoByID($itemID) {
$stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename where IDCurso=?");
$this->throwExceptionOnError();
mysqli_stmt_bind_param($stmt, 's', $itemID);
$this->throwExceptionOnError();
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
$rows = array();
mysqli_stmt_bind_result($stmt, $row->IDCurso, $row->IDModulo, $row->NomeModulo, $row->ModuloAnterior, $row->ModuloSeguinte, $row->IDUnidade, $row->NomeUnidade, $row>UnidadeAnterior, $row->UnidadeSeguinte, $row->IDTopico, $row->NomeTopico, $row->TopicoAnterior, $row->TopicoSeguinte, $row->IDEcra, $row->NomeEcra, $row->EcraAnterior, $row->EcraSeguinte,$row->NumCreditos,$row->PathEcra);
array_push($rows,$row);
while (mysqli_stmt_fetch($stmt)) {
$newstdclass= new stdClass();
mysqli_stmt_bind_result($stmt, $row->IDCurso, $row->IDModulo, $row->NomeModulo, $row->ModuloAnterior, $row->ModuloSeguinte, $row->IDUnidade, $row->NomeUnidade, $row->UnidadeAnterior, $row->UnidadeSeguinte, $row->IDTopico, $row->NomeTopico, $row->TopicoAnterior, $row->TopicoSeguinte, $row->IDEcra, $row->NomeEcra, $row->EcraAnterior, $row->EcraSeguinte,$row->NumCreditos,$row->PathEcra);
$newstdclass= $row;
array_push($rows,$newstdclass);
}
mysqli_stmt_free_result($stmt);
mysqli_close($this->connection);
return $rows;
}
am i doing something wrong?
i can't seem to get my head around this....
forgot to add something, i can get results on my local machine, but not on a remote server, i've checked permissions, adjusted the connection to the server but still it does not work
Question
paxa
hi.
i'm going nuts with a function that returns some values from a table, the code works, no mysql or php errors, but the array is not populated.
it's always returning a null value.
every attempt charles webproxy shows me that the result is null.
here is my code:
/** * Returns the item corresponding to the value specified for the primary key. * * Add authorization or any logical checks for secure access to your data * * @param string $itemID * @return stdClass[] */ public function getCursoInfoByID($itemID) { $stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename where IDCurso=?"); $this->throwExceptionOnError(); mysqli_stmt_bind_param($stmt, 's', $itemID); $this->throwExceptionOnError(); mysqli_stmt_execute($stmt); $this->throwExceptionOnError(); $rows = array(); mysqli_stmt_bind_result($stmt, $row->IDCurso, $row->IDModulo, $row->NomeModulo, $row->ModuloAnterior, $row->ModuloSeguinte, $row->IDUnidade, $row->NomeUnidade, $row>UnidadeAnterior, $row->UnidadeSeguinte, $row->IDTopico, $row->NomeTopico, $row->TopicoAnterior, $row->TopicoSeguinte, $row->IDEcra, $row->NomeEcra, $row->EcraAnterior, $row->EcraSeguinte,$row->NumCreditos,$row->PathEcra); array_push($rows,$row); while (mysqli_stmt_fetch($stmt)) { $newstdclass= new stdClass(); mysqli_stmt_bind_result($stmt, $row->IDCurso, $row->IDModulo, $row->NomeModulo, $row->ModuloAnterior, $row->ModuloSeguinte, $row->IDUnidade, $row->NomeUnidade, $row->UnidadeAnterior, $row->UnidadeSeguinte, $row->IDTopico, $row->NomeTopico, $row->TopicoAnterior, $row->TopicoSeguinte, $row->IDEcra, $row->NomeEcra, $row->EcraAnterior, $row->EcraSeguinte,$row->NumCreditos,$row->PathEcra); $newstdclass= $row; array_push($rows,$newstdclass); } mysqli_stmt_free_result($stmt); mysqli_close($this->connection); return $rows; }am i doing something wrong?
i can't seem to get my head around this....
forgot to add something, i can get results on my local machine, but not on a remote server, i've checked permissions, adjusted the connection to the server but still it does not work
help would be apreciated
thanks in advance
Link to comment
Share on other sites
5 answers to this question
Recommended Posts