ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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:
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, this works on my local machine, but not on a remote server, i've checked permissions, changed the connection string to the server, but doesn't return a thing
help would be apreciated
thanks in advance
Last edited by jonniebigodes; 01-16-2011 at 07:42 PM.
May I ask you a favour? I'm working on a laptop w/ 1280x800, and
find it tortureous to try and read this post; can you replace your
PHP tags w/ plain old CODE tags? Never mind the colours - three way
scrolling to try and read something in its entirety doesn't work for me.
You're using a single copy of $row, without ever properly initializing it.
Your class does the necessary mysqli_real_connect() before this gets used, I presume?
Could you try the following instead?
PHP Code:
public function getCursoInfoByID($itemID) { $stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename where IDCurso=?"); mysqli_stmt_bind_param($stmt, 's', $itemID); mysqli_stmt_execute($stmt);
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.