Tutorial: Create PHP alternative for mysql_result in MySQLi
If you are migrating from PHP 5.5 to a newer version of PHP - you might be interested in a MySQL to MySQLi/PDO migration guide - and use the function mysql_result() you might get a notice (in case your error_reporting is set to show deprecated warnings) that this function is deprecate. Since there is no 1:1 alternative you can build your own alternative in MySQLi like shown below:
function mysqli_result($result, $row, $field = 0) {
// Adjust the result pointer to that specific row
$result->data_seek($row);
// Fetch result array
$data = $result->fetch_array();
return $data[$field];
}
Check out more helpful PHP tutorials or share this page on social media to help others.
Published by David on 4th November, 2014
Would you like to follow BWF or like it? Click here!