猿问

如何修复bind_param“无法通过参数”

我使用的网址:../ accessogiornaliero.php?idplayer = 45ccf2a79ec84c


accessogiornaliero.php:


$query = $mysqli->prepare('UPDATE player SET lastLogin = ?,loginstreak = ? WHERE idplayer = ?');

            $query->bind_param("sis", $qdata, $loginStreak, $_GET["idplayer"]);

            $qdata = $now->format('Y-m-d H:i:s');

            $query->execute();

错误:


[05-May-2019 21:19:05 Europe/Rome] PHP Fatal error:  Uncaught Error: Cannot pass parameter 3 by reference in .../accessogiornaliero.php:62

Stack trace:

#0 {main}

  thrown in .../accessogiornaliero.php on line 62

我哪里错了?


慕斯王
浏览 187回答 2
2回答

红颜莎娜

尝试分配值之前  $query = $mysqli->prepare('UPDATE player SET lastLogin = ?,loginstreak = ? WHERE idplayer = ?');        $qdata = $now->format('Y-m-d H:i:s');        $idplayer =  $_GET["idplayer"];        $query->bind_param("sis", $qdata, $loginStreak,  $idplayer );        $query->execute();

慕姐8265434

我认为您正在尝试传递DateTime对象作为引用?[05-May-2019 21:19:05 Europe/Rome]在$qdata变量上我认为您可以/应该重写$query = $mysqli->prepare('UPDATE player SET lastLogin = ?,loginstreak = ? WHERE idplayer = ?');            $query->bind_param("sis", $qdata, $loginStreak, $_GET["idplayer"]);            $qdata = $now->format('Y-m-d H:i:s');            $query->execute();使用NOW()更简单的MySQL函数。$query = $mysqli->prepare('UPDATE player SET lastLogin = NOW(), loginstreak = ? WHERE idplayer = ?');            $idplayer =  $_GET["idplayer"];            $query->bind_param("is", $loginStreak, $idplayer);                            $query->execute();
随时随地看视频慕课网APP
我要回答