“mysql_result()”是有替代方法的,可以使用mysqli来替换“mysql_result”,使用语句如“mysqli_data_seek($result, $number);”。
mysql_result()有替代方法,可以使用mysqli来替换mysql_result;因为官方自php5.3开始一直推荐mysqli和pdo。
php中mysqli替换mysql_result的官方方法
今天升级了php版本,顺便想把php代码中的mysql连接方式改成mysqli,因为官方自php5.3开始一直推荐mysqli 和 pdo 。不多说了,贴代码// here's a rough replacement using mysqli:
// 错略的使用mysqli替换
if (!function_exists('mysql_result')) {
function mysql_result($result, $number, $field=0) {
mysqli_data_seek($result, $number);
$row = mysqli_fetch_array($result);
return $row[$field];
}
}php官方网址:http://php.net/manual/zh/function.mysql-result.php
相关标签:php
本文原创发布php中文网,转载请注明出处,感谢您的尊重!