Magento - Fatal error: class name must be a valid object or string

I am having trouble installing Magento, and I hope someone can help me.

When I first accessed the site, I unexpectedly began to receive the following error message:

Fatal error: Class name must be a valid object or a string in /app/code/core/Mage/Core/Model/Resource.php on line 215 

This function is called:

 /** * Get connection type instance * * Creates new if doesn't exist * * @param string $type * @return Mage_Core_Model_Resource_Type_Abstract */ public function getConnectionTypeInstance($type) { if (!isset($this->_connectionTypes[$type])) { $config = Mage::getConfig()->getResourceTypeConfig($type); $typeClass = $config->getClassName(); $this->_connectionTypes[$type] = new $typeClass(); } return $this->_connectionTypes[$type]; } 

This is line 215:

 $this->_connectionTypes[$type] = new $typeClass(); 

I was looking for someone with a similar problem, but I had no luck, so I got stuck and really have to solve this problem.

Can anyone help?

+6
source share
1 answer

I had the same problem. Try to add

 <type>pdo_mysql</type> 

in the local.xml file inside the node connection. It should be something like this:

  <default_setup> <connection> <host><![CDATA[localhost]]></host> <username><![CDATA[your_user]]></username> <password><![CDATA[your_pass]]></password> <dbname><![CDATA[your_db]]></dbname> <initStatements><![CDATA[SET NAMES utf8]]></initStatements> <model><![CDATA[mysql4]]></model> <type><![CDATA[pdo_mysql]]></type> <pdoType><![CDATA[]]></pdoType> <active>1</active> </connection> </default_setup> 

And also try checking if your editor added lines or spaces when automatically formatting your xml configuration file. Sometimes the value for the node type (and other nodes) is placed in the line below, and this interrupts the analysis. Therefore, make sure that there are no spaces or line breaks in your XML file.

+9
source

All Articles