GooDFighTy
GooDFighTy

Reputation: 67

Call to a member function children() on a non-object but i need to continue execution

that i need is; Fatal error: Call to a member function children() on a non-object i know the cause of this but i need to continue executing and i can't My problem is that i want to take eight images from my page and im doing this;

do {
        if(is_Object($html2->find("#ficha_fotos",0)->children($j)) === true){
            if($html2->find("#ficha_fotos",0)->children($j)->children(0)->src){
                $imggran = $html2->find("#ficha_fotos",0)->children($j)->children(0)->src."<br />";
                $imggran = explode(".", $imggran);
                $imggran[2] = $imggran[2]."G";
                $salidaimg = implode('.',$imggran);
                echo $salidaimg;
            }
            $j++;
        }else {
            $j++;
        }
    } while($j < 50);

but in some pages i got less than eight so i need to avoid this error and continue executing. thanks and sorry for the inconvenience

Upvotes: 0

Views: 498

Answers (1)

zzlalani
zzlalani

Reputation: 24384

Try this

do {
    $isObject = false;
    if ( is_Object($html2->find("#ficha_fotos",0)) === true && is_Object($html2->find("#ficha_fotos",0)->children($j)) === true ) {
        $isObject = true;
    }
    if($isObject){

Upvotes: 1

Related Questions