Question

I have the controller

<?php

class Onetimescan extends CI_Controller{

    public function index() {
            #LOAD -->>>> LIB ###########
           $this->load->library('session');  ##    LOAD LIBS:  SESSION 
           $this->load->helper('simpledom');

           #LOAD -->>>> MODEL
           $this->load->model('scanmodel');
                $this->scanmodel->loadurlbasedonsessid($this->session->userdata('session_id')); // echo out inserted domain in loadurlbasedonsessid() func
                $sss= $this->session->userdata('tld'); // echo $sss;

       $siteToSearch = file_get_html($sss);
       foreach($siteToSearch->find('form') as $element){
            echo "<h1 style='color:red; '>".$element->action."</h1> <br />";
        }     
    }
}
?>

I'm getting a fatal error of Call to a member function find() on a non-object on this line:

   foreach($siteToSearch->find('form') as $element){

simpledom is a helper I loaded at the top (actually called simpledom_helper.php) which has a file_get_html defined like:

[http://pastebin.com/HaJtKfNb][1]

What am I doing wrong here? I tried definining the function like public function file_get_html{} but that threw errors.

I fixed this all by adding:

$prefix = "http://www.";
                //echo "SSS is:  ".$sss;
           $siteToSearch = file_get_html($prefix.$sss);

FIXED>> The url was trying to get_file_contents(somedomain.com) and was missing the http://www. as a fully qualified domain. This function get_file_contents seems to require the http://www.

Was it helpful?

Solution

Helper functions should be called like this since they are not objects:

$this->load->helper('simpledom');    
$siteToSearch = file_get_html($sss);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top