duanbei2914 2011-04-15 16:16
浏览 35
已采纳

fetch_array与准备好的语句? PHP MYSQL?

For some reason I cannot get this to work for the life of me, I am new to prepared statements!


    $q = $dbc -> prepare ("SELECT * FROM accounts WHERE email = ? && logcount = ''");
    $q -> bind_param ('s', ($_SERVER['QUERY_STRING']));
    $row = $q -> fetch_array(MYSQLI_ASSOC);
    $q -> execute();
    $q -> store_result();
        if ($q -> num_rows == 1) {
            $q = $dbc -> prepare("UPDATE accounts SET logcount = '0' WHERE email = ?");
            $q -> bind_param('s', ($_SERVER['QUERY_STRING']));
            $q -> execute();
            echo '

Congratulations ' . $row['username'] . ' your account is now active!

'; }

Any ideas why $row['username'] will not print? It returns a : Call to undefined method mysqli_stmt::fetch_array()

Thanks.

  • 写回答

3条回答 默认 最新

  • dongliqin6939 2011-04-15 16:21
    关注

    You don't need fetch_array in this case.

    If you want to use get the data from the query, you need to use bind_result and fetch after calling execute.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 ats2837 spi2从机的代码
  • ¥200 wsl2 vllm qwen1.5部署问题
  • ¥100 有偿求数字经济对经贸的影响机制的一个数学模型,弄不出来已经快要碎掉了
  • ¥15 数学建模数学建模需要
  • ¥15 已知许多点位,想通过高斯分布来随机选择固定数量的点位怎么改
  • ¥20 nao机器人语音识别问题
  • ¥15 怎么生成确定数目的泊松点过程
  • ¥15 layui数据表格多次重载的数据覆盖问题
  • ¥15 python点云生成mesh精度不够怎么办
  • ¥15 QT C++ 鼠标键盘通信