简体   繁体   English

error Strict Standards:Error Only variables should be used by reference in C:\\wamp64\\www\\Exercise Files\\CRUD\\crud-mysqli.php on line 545

[英]error Strict standards:Error Only variables should be passed by reference in C:\wamp64\www\Exercise Files\CRUD\crud-mysqli.php on line 545

On a lynda.com tutorial I am getting this error :在 lynda.com 教程中,我收到此错误:

error Strict standards:Error Only variables should be passed by reference in C:\\wamp64\\www\\Exercise Files\\CRUD\\crud-mysqli.php on line 545 error Strict Standards:Error Only variables should be used by reference in C:\\wamp64\\www\\Exercise Files\\CRUD\\crud-mysqli.php on line 545

I can't see in the code where anything is passed by reference.我在代码中看不到任何通过引用传递的内容。
I understand the @ operater is an error operator and I think this is causing the error我知道 @ 操作符是一个错误操作符,我认为这是导致错误的原因

function insert_album_sql( $album )
{
global $CRUD;
$dbh = $CRUD['dbh'];

$query = '
    INSERT INTO album
        ( title, artist, label, released )
        VALUES ( ?, ?, ?, ? )
';

$sth = $dbh->prepare($query);
if($sth) {
    $sth->bind_param("ssss", @$album['title'], @$album['artist'],   @$album['label'], @$album['released'] );
    $sth->execute();
} else {
    error("insert_album_sql: insert prepare returned no statement handle");    
}

// check for errors
$err = $sth->error;
if($err) error( $err );

return($dbh->insert_id);
}

My educated guess is that line 545 is this:我有根据的猜测是第 545 行是这样的:

$sth->bind_param("ssss", @$album['title'], @$album['artist'],   @$album['label'], @$album['released'] );

You have a better chance to determine it for sure than any of us, though, since any decent editor should have a way to either display line numbers or browse to a line by number.不过,您比我们任何人都有更好的机会确定它,因为任何体面的编辑器都应该有办法显示行号或逐行浏览。

From the bind_param() manual page :bind_param()手册页

Binds variables to a prepared statement as parameters将变量绑定到准备好的语句作为参数

That means that the function doesn't read the value.这意味着该函数不读取该值。 Instead, it keeps a reference to the original variable to read it later.相反,它保留对原始变量的引用,以便稍后读取。 If don't provide a raw variable, it cannot work.如果不提供原始变量,它将无法工作。

(Disclaimer: I haven't really tested whether @ in particular actually prevents bind_param() from working because I don't know all PHP internals by heart.) (免责声明:我还没有真正测试过@特别是是否真的阻止了bind_param()工作,因为我不知道所有的 PHP 内部原理。)

Solution: get rid of @ entirely.解决方案:完全摆脱@ You don't want to hide error messages because coding blindly it's neither productive nor fun.您不想隐藏错误消息,因为盲目编码既没有效率也没有乐趣。

A tutorial that uses a global variable to pass the database connection to the function and abuses @ that way is not a reliable source of knowledge to begin with so it's just possible that such strict standards violation is there in the first place.使用全局变量将数据库连接传递给函数并以这种方式滥用@的教程一开始就不是可靠的知识来源,因此最初可能存在如此严格的标准违规行为。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 严格的标准:只有变量才能在第3行的C:\\ wamp \\ www \\ lions \\ admin \\ UploadmemberHandler.php中通过引用传递 - Strict standards: Only variables should be passed by reference in C:\wamp\www\lions\admin\UploadmemberHandler.php on line 3 严格标准:C:\\wamp\\www\\Training session\\con_user.php 中只应通过引用传递变量 - Strict standards: Only variables should be passed by reference in C:\wamp\www\Training session\con_user.php 严格的标准:只有变量应通过引用传递给…-错误行 - Strict Standards: Only variables should be passed by reference in… - error line 烦人的PHP错误:“严格的标准:只有变量应该通过引用传递” - Annoying PHP error: “Strict Standards: Only variables should be passed by reference in” 严格标准:只应通过引用传递变量 - php错误 - Strict Standards: Only variables should be passed by reference - php error 获取错误严格的标准:仅在第20行的register.php中通过引用传递变量 - Getting error Strict Standards: Only variables should be passed by reference in register.php on line 20 (获取错误消息)严格标准:在引用中,仅变量应通过引用传递 - (Getting Error message) Strict Standards: Only variables should be passed by reference in 严格的标准:在创建缩略图时,只能通过引用传递变量”错误 - Strict Standards: Only variables should be passed by reference” error in thumnail creation 错误消息“严格的标准:只应通过引用传递变量” - Error message "Strict standards: Only variables should be passed by reference" Hostinger错误,严格标准只有变量应通过引用传递 - Hostinger error, Strict Standards Only variables should be passed by reference
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM