Jump to content

Error when changing mysQl database


Ecopa

Recommended Posts

Hey

 

We are about to launch our testshop - testshop.one-k.dk - and doing so i was advised by our hosting service that the webshop should be on a seperate database. During development and testing we used the same as the existing webshop, just used another prefix - pstest.

 

I now exported -> imported all the pstest files to the new database along with the "_PREFIX_loffc_block" ones that was present in the old database. 

 

I switched database by changing database name in settings.inc.php in config folder - only change was the database name as the provider, user and password is the same.

 

All good i thought, but i get an error along with an grafical error when i go to the log-in page. See attached file.post-904164-0-73375700-1424774815_thumb.jpg

 

the error code is:

Warning: Invalid argument suppiled for foreach() in /var/www....../classes/country.php on line 131

 

And in that file, surrounding line 131 reads:

 
public static function getCountries($id_lang, $active = false, $contain_states = false, $list_states = true)
{
$countries = array();
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT cl.*,c.*, cl.`name` country, z.`name` zone
FROM `'._DB_PREFIX_.'country` c '.Shop::addSqlAssociation('country', 'c').'
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country` AND cl.`id_lang` = '.(int)$id_lang.')
LEFT JOIN `'._DB_PREFIX_.'zone` z ON (z.`id_zone` = c.`id_zone`)
WHERE 1'.($active ? ' AND c.active = 1' : '').($contain_states ? ' AND c.`contains_states` = '.(int)$contain_states : '').'
ORDER BY cl.name ASC');
Line 131: foreach ($result as $row)
$countries[$row['id_country']] = $row;
 
if ($list_states)
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'state` ORDER BY `name` ASC');
foreach ($result as $row)
if (isset($countries[$row['id_country']]) && $row['active'] == 1) /* Does not keep the state if its country has been disabled and not selected */
$countries[$row['id_country']]['states'][] = $row;
}
return $countries;
 
 
So writing this up i kinda realise it must (or not..?) be something to do with the non prefixed pstest files in the new database.
What do i need to do with them?
 
I changed back to the old database until the issue is resolved so you cant see the error youself.
Edited by Ecopa (see edit history)
Link to comment
Share on other sites

Thx Nemo, Though -

 

I exported -> imported the database again and it seemed to work now without doing further :-s

 

On another note, can i change the prefix used in the database easily? Looks kinda non-pro to have it at "pstest" now when we are out of testing and on a seperate database.

 

Best regards

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...