SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Jan 2012
    Posts
    261
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Zend Database Connection (I think?)

    I downloaded a huge database-driven website focus on living organisms from www.catalogueoflife.org I installed it on my Mac, and the home page displays properly, but none of the links work. I can't get any feedback from their support e-mail address, so I decided to try and troubleshoot it myself (though the code looks WAY over my head).

    Anyway, I can access the home page at http://col2013ac/

    There's a series of links that let you choose a language (English, Spanish, Russian, etc.). They work; if I click Spanish, all the text changes to Spanish.

    However, if I click any of the other links, like http://col2013ac/browse/tree, I get this message:

    * * * * *

    Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator, you@example.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.

    * * * * *

    Could that indicate a faulty connection with my database, or does it suggest another problem?

    The site is installed on my Mac at /Applications/MAMP/htdocs/col2013ac and the database is at /Applications/MAMP/db/mysql/CoL2013ac

    Even if this isn't the immediate problem, I'd like to learn how to manipulated and modify this website, including moving the database to a new location.

    So I did a search for "database connection" and got several hits. I posted snippets of code from several files in hopes that someone might be able to give me a clue about what's going on here. I assume the name of the database is CoL2013ac, but how can I found out the username and password? If I can figure that out, then maybe I can figure out how to replace them with my own username and password.

    Or have I opened a can of worms that I'll probably never be able to work with without learning a new program (e.g. Zend)?

    Thanks.

    Code:
    // libray/Zend/Db/Adapter/Abstract.php
    
        protected $_defaultProfilerClass = 'Zend_Db_Profiler';
    
        /**
         * Database connection
         *
         * @var object|resource|null
         */
        protected $_connection = null;
    
    /////////////////
    
        protected function _checkRequiredOptions(array $config)
        {
            // we need at least a dbname
            if (! array_key_exists('dbname', $config)) {
                /** @see Zend_Db_Adapter_Exception */
                require_once 'Zend/Db/Adapter/Exception.php';
                throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'dbname' that names the database instance");
            }
    
            if (! array_key_exists('password', $config)) {
                /**
                 * @see Zend_Db_Adapter_Exception
                 */
                require_once 'Zend/Db/Adapter/Exception.php';
                throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'password' for login credentials");
            }
    
            if (! array_key_exists('username', $config)) {
                /**
                 * @see Zend_Db_Adapter_Exception
                 */
                require_once 'Zend/Db/Adapter/Exception.php';
                throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'username' for login credentials");
            }
        }
    
        /**
         * Returns the underlying database connection object or resource.
         * If not presently connected, this initiates the connection.
         *
         * @return object|resource|null
         */
        public function getConnection()
        {
            $this->_connect();
            return $this->_connection;
        }
    
    // /library/Zend/Db/Table/Row/Abstract.php
    
        /**
         * Setup to do on wakeup.
         * A de-serialized Row should not be assumed to have access to a live
         * database connection, so set _connected = false.
         *
         * @return void
         */
        public function __wakeup()
        {
            $this->_connected = false;
        }
    
    // /library/Zend/Db/Table/Rowset/Abstract.php
    
        /**
         * Setup to do on wakeup.
         * A de-serialized Rowset should not be assumed to have access to a live
         * database connection, so set _connected = false.
         *
         * @return void
         */
        public function __wakeup()
        {
            $this->_connected = false;
        }
    
    // /library/Zend/Test/PHPUnit/DatabaseTestCase.php
    
    abstract class Zend_Test_PHPUnit_DatabaseTestCase extends PHPUnit_Extensions_Database_TestCase
    {
        /**
         * Creates a new Zend Database Connection using the given Adapter and database schema name.
         *
         * @param  Zend_Db_Adapter_Abstract $connection
         * @param  string $schema
         * @return Zend_Test_PHPUnit_Db_Connection
         */
        protected function createZendDbConnection(Zend_Db_Adapter_Abstract $connection, $schema)
        {
            return new Zend_Test_PHPUnit_Db_Connection($connection, $schema);
        }
    
        /**
         * Convenience function to get access to the database connection.
         * 
         * @return Zend_Db_Adapter_Abstract
         */
        protected function getAdapter()
        {
            return $this->getConnection()->getConnection();
        }
    
    // /library/Zend/Test/PHPUnit/Db/DataSet/QuerDataSet.php
    
    class Zend_Test_PHPUnit_Db_DataSet_QueryDataSet extends PHPUnit_Extensions_Database_DataSet_QueryDataSet
    {
        /**
         * Creates a new dataset using the given database connection.
         *
         * @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $databaseConnection
         */
        public function __construct(PHPUnit_Extensions_Database_DB_IDatabaseConnection $databaseConnection)
        {
            if( !($databaseConnection instanceof Zend_Test_PHPUnit_Db_Connection) ) {
                require_once "Zend/Test/PHPUnit/Db/Exception.php";
                throw new Zend_Test_PHPUnit_Db_Exception("Zend_Test_PHPUnit_Db_DataSet_QueryDataSet only works with Zend_Test_PHPUnit_Db_Connection connections-");
            }
            $this->databaseConnection = $databaseConnection;
        }

  2. #2
    SitePoint Addict
    Join Date
    Jan 2012
    Posts
    261
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Update: Well, I guess I figured out how to find out what the password is - just do a search for "password." Actually, I did that before without success; I must have misspelled password.

    Anyway, I tried it again and got over 130 hits, very confusing. I think some of the passwords might be for visitors who want to register with the website.

    The code below may have the answer:

    Code:
    define ("DB_ADRES", 'localhost');
    define ("DB_USERNAME", 'root');
    define ("DB_PASSWORD", 'pass');
    define ("DB_NAME", 'database');
    
    include_once 'classes/class.database.php';
    
    //Connect to databases
    $database = new database(DB_NAME, DB_USERNAME, DB_PASSWORD, DB_ADRES);
    If the username and password are really "root" and "pass," then I should be able to write a query that displays a table from that database, so I'll give that a try.

  3. #3
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,388
    Mentioned
    45 Post(s)
    Tagged
    12 Thread(s)
    Hi Chavista,

    There's nothing in the error message that suggests a DB problem, so the first thing to do would be to take a look at the error log. I did a quick search and the PHP error log should be located at /Applications/MAMP/logs/php_error.log

    Also, I followed the link for the Catalogue of Life, but I couldn't see the software you're talking about to download anywhere.. could you provide a more specific link or some instructions on where to look?

    From your description of the problem, it could possibly have something to do with URL rewriting, but that's just a shot in the dark.

  4. #4
    SitePoint Addict
    Join Date
    Jan 2012
    Posts
    261
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found the php_error.log right where you said it would be. I couldn't open it with Edit or TextWrangler and was shocked to discover that the file size is almost one GB! How do people manage error logs? Could I just delete the file and create a new file with the same name?

    In the meantime, I was able to open it with Console, and I copied and pasted a few lines at the end of this post.

    Here's the link to the Catalogue of Life's download page -- http://www.catalogueoflife.org/conte...cklist-archive

    However, none of the links seem to work. They send me a CD with their annual upgraded list every year, and I installed it from that.

    I, too, though the problem might involve URL rewriting after I discovered a file named alias.conf. I asked some questions about it on this thread.

    In the meantime, taxonomy vs databases is a complex and controversial field -- http://iphylo.blogspot.com/2013/11/c...catalogue.html

    I hope no one thinks I'm being rude if I don't reply to this thread for a while. I'm going to be in a WiFi cafe for another hour or two at the most, and I might then be without Internet access for two or three days.

    Obrigado.


    Here's some code from php_error.log...

    Object(Zend_Controller_Response_Http))
    #10 /var/www/testcol/library/Zend/Application/Bootstrap/Bootstrap.php(77): Zend_Controller_Front->dispatch()
    #11 /var/www/testcol/library/Zend/Application.php(358): Zend_Application_Bootstrap_Bootstrap->run()
    #12 /var/www/testcol/public/index.php(66): Zend_Application->run()
    #13 {main}
    2013-03-25T10:11:30+00:00 CRIT (2): exception 'Zend_Db_Adapter_Mysqli_Exception' with message 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' in /var/www/testcol/library/Zend/Db/Adapter/Mysqli.php:333
    Stack trace:
    #0 /var/www/testcol/library/Zend/Db/Adapter/Abstract.php(832): Zend_Db_Adapter_Mysqli->_connect()
    #1 /var/www/testcol/library/Zend/Db/Adapter/Abstract.php(902): Zend_Db_Adapter_Abstract->quote('13029472', NULL)
    #2 /var/www/testcol/library/Zend/Db/Select.php(988): Zend_Db_Adapter_Abstract->quoteInto('ttt.parent_id =...', '13029472', NULL)
    #3 /var/www/testcol/library/Zend/Db/Select.php(463): Zend_Db_Select->_where('ttt.parent_id =...', '13029472', NULL, true)
    #4 /var/www/testcol/application/models/Search.php(1082): Zend_Db_Select->where('ttt.parent_id =...', '13029472')
    #5 /var/www/testcol/application/controllers/BrowseController.php(310): ACI_Model_Search->getTaxonChildren('13029472')
    #6 /var/www/testcol/application/controllers/BrowseController.php(55): BrowseController->_getTaxonChildren('13029472')
    #7 /var/www/testcol/library/Zend/Controller/Action.php(513): BrowseController->treeAction()
    #8 /var/www/testcol/library/Zend/Controller/Dispatcher/Standard.php(289): Zend_Controller_Action->dispatch('treeAction')
    #9 /var/www/testcol/library/Zend/Controller/Front.php(946): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
    #10 /var/www/testcol/library/Zend/Application/Bootstrap/Bootstrap.php(77)d: Zend_Controller_Front->dispatch()
    #11 /var/www/testcol/library/Zend/Application.php(358): Zend_Application_Bootstrap_Bootstrap->run()
    #12 /var/www/testcol/public/index.php(66): Zend_Application->run()
    #13 {main}


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •