Strict Standards: Only variables should be passed by reference

前端 未结 3 1205
一向
一向 2021-01-23 09:11

My PHP script is displaying an error:

Strict Standards: Only variables should be passed by reference in C:\\....*.php on line 551
相关标签:
3条回答
  • 2021-01-23 09:37

    Your second parameter 'strtoupper($a_user[$db_translation['login']])' must be a reference to a variable.

    doc : Ref to bindparam

    the 'mixed &$variable' in the doc say that it must be a reference (it's the '&')

    you can create a variable, and put the result of 'strtoupper($a_user[$db_translation['login']])' into it. For example :

    $foo = strtoupper($a_user[$db_translation['login']]);
    $res->bindParam(':acc', $foo, PDO::PARAM_STR);
    

    Hope this help

    0 讨论(0)
  • 2021-01-23 09:42

    Use:

    $param = strtoupper($a_user[$db_translation['login']]);
    $res->bindParam(':acc', $param, PDO::PARAM_STR);
    
    0 讨论(0)
  • 2021-01-23 09:47

    use bindValue() because bindParam() second arg is a reference like

    $res->bindValue(':acc', strtoupper($a_user[$db_translation['login']]));
    

    if you want to use bindParam then you have to store your statement into one variable and pass that variable as an argument. like.

    $test = strtoupper($a_user[$db_translation['login']];
    $res->bindParam(':acc', $test), PDO::PARAM_STR);
    
    0 讨论(0)
提交回复
热议问题