simple-mysqli
simple-mysqli copied to clipboard
Warning: Trying to access array offset on value of type null in...
This function returns error Warning: Trying to access array offset on value of type null in... if $result is null.
public function getResult($query, $pos = 0)
{
if($query) {
$results = $this->query($query);
$result = $results->fetch_array();
return $result[$pos];
}
}
Must be updated:
public function getResult($query, $pos = 0)
{
if($query) {
$results = $this->query($query);
$result = $results->fetch_array();
if($result)
{
return $result[$pos];
}
}
}