mysqli_fetch_object() issue [solved]
Posted: Tue Jun 12, 2012 4:01 am
The code below is self-explanatory and the problem is that var_dump($obj) is returning NULL; database connection is ok, query is fine when i print it to the browser. The commented section where the mysqli_error() function returns no errors; i'm confused about where the issue is and would appreciate any ideas about possible causes. Thanks in advance.
Code: Select all
<?php
protected function _retrieveIndividualSurveyPId($subjectNum)
{
$subjectNum = trim($subjectNum);
$query = "SELECT `parentsubjectid` FROM `is_table` WHERE
`subjectnum` = '" . mysqli_real_escape_string($this->_dbResource,
$subjectNum) . "' ";
$sql = mysqli_query($this->_dbResource, $query);
//
/*
$sql = mysqli_query($this->_dbResource, $query) or
die(mysqli_error($this->_dbResource));
*/
$obj = mysqli_fetch_object($sql);
var_dump($obj);
}
?>