問題描述
我只是需要幫助解決這個(gè)我不太明白的 PHP 錯(cuò)誤:
I just need help on this PHP error which I do not quite understand:
致命錯(cuò)誤:無法在第 13 行的/web/stud/openup/inactivatesession.php 中通過引用傳遞參數(shù) 2
Fatal error: Cannot pass parameter 2 by reference in /web/stud/openup/inactivatesession.php on line 13
<?php
error_reporting(E_ALL);
include('connect.php');
$createDate = mktime(0,0,0,09,05,date("Y"));
$selectedDate = date('d-m-Y', ($createDate));
$sql = "UPDATE Session SET Active = ? WHERE DATE_FORMAT(SessionDate,'%Y-%m-%d' ) <= ?";
$update = $mysqli->prepare($sql);
$update->bind_param("is", 0, $selectedDate); //LINE 13
$update->execute();
?>
這個(gè)錯(cuò)誤是什么意思?如何修復(fù)此錯(cuò)誤?
What does this error mean? How can this error be fixed?
推薦答案
該錯(cuò)誤意味著第二個(gè)參數(shù)應(yīng)該是對變量的引用.
The error means that the 2nd argument is expected to be a reference to a variable.
由于您處理的不是變量,而是值 0 的整數(shù),因此會產(chǎn)生上述錯(cuò)誤.
Since you are not handing a variable but an integer of value 0, it generates said error.
要避免這種情況,請執(zhí)行以下操作:
To circumvent this do:
$a = 0;
$update->bind_param("is", $a, $selectedDate); //LINE 13
如果您想了解正在發(fā)生的事情,而不是僅僅修復(fù)您的致命錯(cuò)誤
,請閱讀以下內(nèi)容:http://php.net/manual/en/language.references.pass.php
In case you want to understand what is happening, as opposed to just fixing your Fatal error
, read this: http://php.net/manual/en/language.references.pass.php
這篇關(guān)于PHP 錯(cuò)誤:“無法通過引用傳遞參數(shù) 2"的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!