Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8498771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:29:34+00:00 2026-06-11T00:29:34+00:00

I have a script that parses certain elements from a webpage and stores them

  • 0

I have a script that parses certain elements from a webpage and stores them in a mysql db. Everything works fine until I try to split an element and store the resulting data into the db. Any ideas what might be wrong?
Here’s the page I’m parsing: http://www.ratemyprofessors.com/SelectTeacher.jsp?sid=953

Here’s my code:

<?php
include('simple_html_dom.php'); 

//connect to db (code emitted)

prof_List("http://www.ratemyprofessors.com/SelectTeacher.jsp?sid=953");

function prof_name($url)
{
    // collect data
    echo $url;
    $data = new simple_html_dom();  
    $data->load_file($url);
    $profName = $data->find("//*[@id=profName]", 0);
    $profName = strip_tags($profName);
    echo "Full Name: " . $profName = trim($profName);
    list($first, $last) = explode("&nbsp;", $profName);
    echo "fname: " .  $first;
    echo "lname: " . $last;

    //call mysql function
    insert_row($profName, $first, $last);

}


function insert_row($profName, $first, $last)
{
    $sql1="INSERT INTO PROFESSOR(name, firstname, lastname) VALUES('$profName','$first', '$last')";
    $sql1=strip_tags($sql1);
    echo $sql1;
    mysql_query($sql1) or die(mysql_error());  
    echo "Data Inserted!"; 
}


function prof_List($mainURL)
{

    $list = new simple_html_dom();  
    $list->load_file($mainURL);
    $profLinks = $list->find("//*[@class=profName]/a");
    foreach($profLinks as $profLink)
    {
        $profU=$profLink->href;
        echo $profURL = "http://www.ratemyprofessors.com/" . $profU;
        prof_name($profURL);
    }

}

?>

Here’s my output:

Connected to MySQL
Connected to Databasehttp://www.ratemyprofessors.com/SelectTeacher.jsp?the_dept=All&sid=953&orderby=TLName&toggel=truehttp://www.ratemyprofessors.com/SelectTeacher.jsp?the_dept=All&sid=953&orderby=TLName&toggel=trueFull Name: fname: lname: INSERT INTO PROFESSOR1(name, firstname, lastname) VALUES('','', '')Data Inserted!http://www.ratemyprofessors.com/ShowRatings.jsp?tid=861228http://www.ratemyprofessors.com/ShowRatings.jsp?tid=861228
Fatal error: Call to a member function find() on a non-object in /Users/user1/Sites/simple_html_dom.php on line 879
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:29:36+00:00Added an answer on June 11, 2026 at 12:29 am

    I don’t think you can use find() on simple_html_dom().

    Try this:

    $data = new simple_html_dom();  
    $data->file_get_html($url);
    $profName = $data->find("//*[@id=profName]", 0);
    

    This link provides a great, basic example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings, I have a bash script that parses ZIP files we receive from a
We have a script that parses XML feeds from user generated sources which from
I currently have a Perl CGI script that parses incoming XML requests using XML::Simple
I have a jQuery tab script that gets content from a PHP file defined
I have written a Python script that checks a certain e-mail address and passes
I have a script that displays images based on certain conditions. When none of
I'm trying to write a script that parses an email and looks for certain
Hopefully this makes sense. I have a php script, magpierss, that parses a RSS
I have a script that parses the filenames of TV episodes (show.name.s01e02.avi for example),
I have a script that calls ffprobe, parses its output and outputs it to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.