2013-05-27 76 views
1

我的PHP腳本顯示錯誤傳遞:嚴格的標準:只有變量應參考

Strict Standards: Only variables should be passed by reference in C:\....*.php on line 551 

的代碼如下:

function trinity_premissions() 
{ 
     global $ACC_PDO, $WEB_PDO, $a_user, $db_translation; 

     $end = false; 

     $res = $WEB_PDO->prepare("SELECT acc_login, gmlevel FROM `accounts_more` WHERE UPPER(acc_login) = :acc"); 
/* 551 */$res->bindParam(':acc', strtoupper($a_user[$db_translation['login']]), PDO::PARAM_STR); 
     $res->execute(); 

     if ($res->rowCount() == 1) 
     { 
       $s2 = $res->fetch(PDO::FETCH_ASSOC); 
       if ($s2['gmlevel']<>'') 
       { 
         return $s2['gmlevel']; 
       } 
     } 
     unset($res); 
} 

我不知道是什麼問題。誰能幫我?

+0

可能重複(HTTP://計算器.COM /問題/ 2354609 /嚴格標準的,只有變量,應待通過按參考) –

回答

0

使用:

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

你的第二參數 'strtoupper($ a_user [$ db_translation [' 登錄 ']])' 必須是對變量的引用。

DOC:Ref to bindparam

在doc的「混合& $變量」說,它必須是引用(它是「&」)

您可以創建一個變量,並把結果'strtoupper($ a_user [$ db_translation ['login']])'。 例如:

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

希望這有助於

2

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); 
[嚴格的標準:只有變量應該按引用傳遞]的
相關問題