So briefly I have a framework class that I'm using that work perfect except with the issue I'm currently having. Problem is this, everything displays on the page as expected until the form on the page is submitted and the ISSET at the top is true:
if(isset($addAccount)){
$SP = new SP_functions();
echo $SP->addAccount($UID,$name,$type,$code,$balance,$website);
}
Once it passes through the isset and then its the code listed below I get this error message: Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given. I'm not sure what this means so I don't understand the problem, this isset function should have nothing to do with what happens below that I would think.
The code that runs basically goes through this route:
$account = new AllAccountInfo();
$result = $account->loadByFields("UID",$UID);
foreach($result as $a){
//display stuff
}
The loadByFields function looks like this:
function loadByFields($fields, $values, $options="") {
$fields = explode(',',$fields);
$values = explode(',',$values);
$loops = count($fields);
$selectedFields = "*";
if($options!="") {
foreach($options as $i => $v) {
if($i=='fields') $selectedFields = $v;
}
}
$query = "SELECT ".$selectedFields." FROM ". $this->tableName ." WHERE";
for($i=0; $i<$loops; $i++) {
if($i==0) $query .= " " .mysqli_real_escape_string($this->link,$fields[$i]). " = '" .mysqli_real_escape_string($this->link,$values[$i]). "'";
else $query .= " AND " .mysqli_real_escape_string($this->link,$fields[$i]). " = '" .mysqli_real_escape_string($this->link,$values[$i]). "'";
}
if($options!="") {
foreach($options as $i => $v) {
if($i=='group') $groupByCond .= " GROUP BY ".mysqli_real_escape_string($this->link,$v)." ";
if($i=='order') $orderByCond = " ORDER BY ".mysqli_real_escape_string($this->link,$v)." ";
}
$query .= $groupByCond.$orderByCond;
}
// $query = SELECT * FROM allAccountInfo WHERE UID = '8' every time
return $this->loadArrayFromQuery($query);
}
which then calls this method, loadArrayFromQuery:
function loadArrayFromQuery($query) {
$result = $this->executeQuery($query);
$return = array();
while ($rows = mysqli_fetch_array($result)) //THIS IS THE LINE THAT IS FAILING
{
$return[] = $this->loadFromArray($rows);
}
return $return;
}
which calls this:
function executeQuery($query) {
mysqli_select_db($this->link, $this->db_name);
$this->counter();
$result = mysqli_query($this->link, $query);
return $result;
}
Thanks in advance to the person who helps to resolve this.