Search code examples
phppear

Pear site moved to new host, some pages not working


I have an old shared hosting plan and I am moving the site to a new VPS hosting plan. It was coded in PHP.

The site moved successfully, but when I try to access a page I get this error:

    Fatal error: Call to undefined method DB_DataObject_Error::getDatabaseConnection() in /var/www/mysite.com/public_html/ss/index.php on line 11

Ring any bells as to why this is happening? I am not familiar with pear, so figured id post this here before I spend many hours trying to figure this one out.

edit: And if I uncomment out those lines, the rest of the page seems to work (cant test most of it ATM tho)... I wonder if this can be a deprecated method?


Solution

  • My problem was my database.INI file that DataObject loads did not know what DB to use (it was set wrong). So any place in the code depending on an instance of the DataObject would fail. Here is code that can give you a better error message (as opposed to calling a method that does not exist and getting a php error):

    $userobject = DB_DataObject::factory($tablename);
    if (PEAR::isError($userobject)) 
    {
       echo $userobject->message;
    }