Moving to mysqli, mysql_result

2019-07-11 14:36发布

问题:

I am converting my project from mysql to mysqli and my problem is that mysqli_result() does not work with my old code. My old code is: mysql_result($res,0,0);

When I try adding mysqli_result() with my old code it will not work.

Is there another way that'll work with my old parameters?

回答1:

mysqli_result() will not work with your old parameters so you need to create a new function, Here is the code for a function that'll work with your old prameters:

function mysqli_result($res, $row, $field=0) { 
    $res->data_seek($row); 
    $datarow = $res->fetch_array(); 
    return $datarow[$field]; 
}


标签: php mysql mysqli