below is a handy function i inherited that (in the old mysql) allowed a single rowXcolumn (scalar) value to be returned
by using a one-line function call (instead of $results = and then $row['fieldname'] = the value you want)
with mysqli it is returning the error shown at the bottom.
any help with what was not updated properly for mysqli conventions?
thanks!
ex usage:
$NumLineItems = db_sql("SELECT COUNT(*) FROM tblSales_order_details WHERE so_header_key = 30 ");
echo $NumLineItems;
definition
function db_sfq ($query)
{
$result = db_sql($query); // this function works fine
if ($result)
{
$row = mysqli_fetch_array($result);
return $row[0]; // only one field scalar was requested
}
}// end db_SingleFieldQuery
error
Catchable fatal error: Object of class mysqli_result could not be converted to string
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.