fetch_array与准备好的语句? PHP MYSQL? [英] fetch_array with prepared statement? PHP MYSQL?

查看:76
本文介绍了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!

有什么想法为什么不能打印$ row ['username']吗?它返回一个: 调用未定义的方法mysqli_stmt :: fetch_array()

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

谢谢.

推荐答案

在这种情况下,您不需要fetch_array.

You don't need fetch_array in this case.

如果要使用从查询中获取数据,则需要使用 bind_result fetch execute 后.

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

这篇关于fetch_array与准备好的语句? PHP MYSQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆