2014-12-23 3 views
0

메신저 다른 스크립트에서 함수와 변수를 호출하여 ascript 내 변수에 할당 값을 시도하지만, 현재 점점 오류가 말하는 메신저다른 스크립트에서 변수를 호출

정의되지 않은 속성 :

에서 stdClass : $ 소년을

정의되지 않은 속성 : 내 스크립트라는 스크립트 report.php에서 함수를 호출

메신저에서 stdClass : $ 여자를

$report = new Report(); 
$log = $report->projectReport($ID); 
if($log != false){ 
    $Boys = $log->Boys; 
    $Girls = $log->Girls; 
    print_r($Boys); 
    print_r($Girls); 
} 

return $log; 
+0

$ mat은 무엇입니까? $ multfs는 $ multis의 철자가 틀린 버전입니까? 당신의 방법은 무엇을 반환합니까? $ log를 stdClass 객체로 사용하지만 메소드의 결과에 따라 배열이나 다른 것일 수 있습니다. 명확히하십시오. – MaGnetas

+0

죄송합니다 ... 실수로 코드를 편집했습니다 ... –

+2

'projectReport'는 값을 반환하지 않습니다 ... –

답변

0

당신의 $ 로그가 거짓 없다 내 스크립트

public function projectReport($ID){ 
    $get_con = $this->getConnection(); 
    $result = mysql_query($query, $get_con); 
    $rep = new stdClass(); 
    if(false !== $result){ 
     $multis = array(); 
     while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ 
      $count = new stdClass(); 
      $count->Boys = (int)$row['males']; 
      $count->Girls = (int)$row['females']; 
      $multis[] = $count; 

     } 
     $rep->multiples = $multis; 

    } 
return $rep; 
    } 

report.php 함수 본문은 그래서 당신은 그것을 확인 할 필요가 없습니다. 또한 다중 속성이 누락되었을 수 있습니다.

이 시도 :

$report = new Report(); 
$log = $report->projectReport($ID); 
if(property_exists($log, 'multiples')){ //check if multiples attribute exists 
    foreach ($log->multiples as $m)  //walk through every multiples record 
    { 
     $Boys = $m->Boys;    //get Boys and Girls attributes values and print them 
     $Girls = $m->Girls; 
     print_r($Boys); 
     print_r($Girls); 
    } 
} 

나는 그것이 당신이 달성 싶은 게 아니에요 확신 해요,하지만 당신이 지금까지있어 내용에 따라 작동합니다 어떻게.

+0

덕분에이 chk이 !! –

관련 문제