문제

i create my own function with count of data.

Here is my function.

   function  Test($data){
     global $acc;
     $count = $acc->get_var("SELECT Count(*) FROM _users WHERE ID='$data'");
     if($count == 0)
     {
       return true;
     }else{
       return false;
     }
   }

But i got This is error : "PHP Catchable fatal error: Object of class stdClass could not be converted to string In This is Line $count = $acc->get_var("SELECT Count(*) FROM _users WHERE ID='$data'"); I try var_dump in function and Other ezSQL methods (query,num_rows) but i got every same error.

-- Edit: Problem solved. I wrong posted $data

도움이 되었습니까?

해결책

Please make sure that

$data

is not an array

다른 팁

its better practice to pass $acc by reference

function  Test($data, &$acc){

     $count = $acc->query("SELECT Count(*) FROM _users WHERE ID='$data'");
     if($count == 0)
     {
       return true;
     }else{
       return false;
     }

}

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top