drrw8672 2017-05-10 11:12
浏览 9

PHP - 我有两个功能一起工作,但现在给了我一个错误,在它不存在之前

Now they aren't working anymore, but before they were

function perm1($conn)
{
$stmt = odbc_prepare($conn, 'SELECT * FROM nivel_acesso');
$success = odbc_execute($stmt);
echo "erro 1";
echo '<ul class="perm">';
echo "erro 2";
while($myRow = odbc_fetch_array($stmt))
{
echo "erro 3";
    $rows = $myRow;
    echo '<li>';
    echo "erro 4";
    echo'<input type="checkbox" name="perm'.$rows["nivel"].'" value="'.$rows["nivel"].'"><label for="perm'.$rows["nivel"].'">'.mb_convert_encoding($rows["descricao"], 'utf8', 'latin1').'</label>';
    echo '</li>';
    echo "erro 5";
}
echo "erro 6";
echo '</ul>';
echo "erro 7";
if(empty($rows))
{
    echo "erro 8";
    return $nada = "macacos";
    echo "erro 9";
}

echo "erro 10";
return $rows;
}

That's my function to show a group of checkboxes with a list of permissions from my database, the query is fine and the connection to.

function utf8_converter($array){
array_walk_recursive($array, function(&$item, $key){
    if(!mb_detect_encoding($item, 'utf-8', true)){
        $item = utf8_encode($item);
    }
});
return $array;
}

That's my function that I use to get the utf-8 of the inputs I get from the database.

When I use something like utf8_converter(perm1($conn)) it gives me this error:

Warning: array_walk_recursive() expects parameter 1 to be array, string given in [Directory of the file here + file name].php on line 35

Line 35 is:

function utf8_converter($array){
array_walk_recursive($array, function(&$item, $key){
    if(!mb_detect_encoding($item, 'utf-8', true)){
        $item = utf8_encode($item);
    }
});<--This one here
return $array;
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题