Jump to content

Getting country list is showing fine on my localhost but its not showing in another setup?


prestashop_newuser

Recommended Posts

Hi,

 

I am doing a small module. In that module I want to get all the country name in dropdown list. For that I just used this code

 



$countrylist = "SELECT pcl.`name`,pc.`iso_code` FROM `"._DB_PREFIX_."country_lang` pcl,ps_country pc  WHERE pcl.`id_country`=pc.`id_country` and pcl.`id_lang`='$defaultLanguage'" ;
    $countries = Db::getInstance()->ExecuteS($countrylist);
    $this->_html .= '
      <select name="country_name" class="required"><option value="select">Select</option>';
      foreach($countries as $country) {
        $this->_html .= '<option id="'.$country['name'].'" value="'.$country['name'].'">'.$country['name'].'</option>';
       }


This one is working fine on my localhost. It is showing all the country name in list. But when the same module is installed with another prestashop installed(The installation was done by one click installation setup on a linux server) did not worked. It did not showed any country name in dropdown list. 

I had checked the database. It had the table prefix prst_ and on my localhost I have table prefix ps_ . So can someone kindly tell me what's the problem here?

 

Link to comment
Share on other sites

when you try to run this query in phpmyadmin. you've got results?

 

Hi,

Thanks for giving the direction. I just made run the query in phpmyadmin of live server and I got the error. As prestashop has been installed on the server by one click and it has taken prst as its table prefix. But in my code where I am getting error is like this

"SELECT pcl.`name`,pc.`iso_code` FROM `"._DB_PREFIX_."country_lang` pcl,ps_country pc  WHERE pcl.`id_country`=pc.`id_country` and pcl.`id_lang`='$defaultLanguage'" ;

Here you can see I have taken ps_country in my query. I just changed  ps_country as `"._DB_PREFIX_."country` and it worked. Thanks for the help.

Edited by prestashop_newuser (see edit history)
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...