0

After I updated my php to 5.3 this error started to showing.

Strict Standards: Only variables should be passed by reference in /var/www/site/Functions/Cases.php on line 108 Strict Standards: Only variables should be passed by reference in /var/www/site/Functions/Cases.php on line 102 Strict Standards: Only variables should be passed by reference in /var/www/site/Functions/Cases.php on line 102

I would like to know how to fix it!

  function CaseID ( $id ) {
              return array_pop ( explode ( '-' , $id ) ) ; 
       } // line 102

       function GetCaseByID ( $caseID ) {
             $db = Connection ( 'db_misc' ) ;
             $sql = $db->prepare ( 'SELECT * FROM `t_cases` WHERE cid = :cid' ) ;
             $sql->bindParam ( ':cid' , CaseID ( $caseID ) , PDO::PARAM_INT ) ; // line 108
             $sql->execute ( ) ;
             return $sql->fetch ( PDO::FETCH_ASSOC ) ; 
       }
John Conde
  • 217,595
  • 99
  • 455
  • 496
Jefferson Filho
  • 91
  • 1
  • 12
  • 2
    `PDOStatement::bindParam` takes a *reference* to a variable. Use `bindValue` instead. (Also, look at all the existing "only variables should be passed by reference" questions in the sidebar. Plenty of explanations there.) – DCoder May 25 '13 at 14:29
  • Thanks! Sorry about it! I checked lot of posts, but I'm still beginner and I couldn't find a example with function so I was bit confused sorry! Thanks for your help! – Jefferson Filho May 25 '13 at 14:41

1 Answers1

1
function CaseID ( $id ) {
          $array = explode ( '-' , $id );
          return array_pop ( $array ) ; 
   }

(The explanation is already in the strict error :))

Sam
  • 2,950
  • 1
  • 18
  • 26
  • Thank you very much! Yeah I checked them all! But I'm still a beginner wasn't me who made this website was my friend and he gave it to me so I'm learning PHP from it, so I couldn't find a example with function so I was bit confused! Sorry about it! And thanks again! – Jefferson Filho May 25 '13 at 14:40