dongxiong1941 2017-08-13 14:35
浏览 73
已采纳

替代mysqli的odbc_result方法

A few days ago I have developed a PHP project with mssql server database. Right now I need to change the MSSQL database to MySQL database. Previously I have used the odbc_result method but I am converting the all methods of odbc to those of mysqli procedural. So I need a function that works like odbc_result for mysqli – which one is it? I am trying to use mysqli_result but it throws an error "Call to undefined function mysqli_result()". Below I have menthid the function:

function checkCountry($con)
{
if ($con != '') {

    $cCodeList = array();
    $i = 0;

    $checkCountrySql = "SELECT country_code FROM country";
    $checkCountyResult = mysqli_query($con, $checkCountrySql);
    while (mysqli_fetch_row($checkCountyResult)) {
        for ($j = 1; $j <= mysqli_num_fields($checkCountyResult); $j++) {
            $ar = mysqli_result($checkCountyResult, $j);
        }
        $cCodeList[$i] = $ar;
        $i++;
    }

    return $cCodeList;
    }
}

So what is the alternative of odbc_result for mysqli?

  • 写回答

1条回答 默认 最新

  • douzai3399 2017-08-13 14:42
    关注

    i am trying to use mysqli_result but it was throwing an error " Call to undefined function mysqli_result() ".

    Because there's no mysqli_result() function available in MySQLi.

    Now look at the for loop, you're overwriting $ar in each iteration of the loop. In fact, you don't need this for loop at all, simply change your while loop in the following way,

    while ($row = mysqli_fetch_row($checkCountyResult)) {
        $cCodeList[] = $row;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器