Welcome Guest, Not a member yet? Register   Sign In
PHP Error & DB Error - urgent help needed
#1

[eluser]vrsupport[/eluser]
In both the be_goldrate and be_country tables is a column country_id. So the column does exist. Please tell me what I am doing wrong.


WARNING & ERROR
-----------------
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/blueplan/public_html/gold/modules/gold/controllers/admin/gold.php:2)

Filename: codeigniter/Common.php

Line Number: 360


A Database Error Occurred
Error Number: 1054

Unknown column ‘g.country_id’ in ‘where clause’

SELECT `g`.*, `c`.`country_name` as country FROM (`be_goldrate` as g) LEFT JOIN `be_country` as c ON `c`.`country_id`=`g`.`country_id` WHERE `g`.`country_id` = ‘1’ ORDER BY `g`.`gold_id` desc LIMIT 1




CODE
------------------------------
function listGold() {
$countries = $this->country_model->getCountries()->result();
$goldrates = array();
foreach($countries as $country) {
$q = $this->goldrate_model->getGoldrate(array('g.country_id'=>$country->country_id), 'g.gold_id desc', array('limit'=>1, 'offset'=>0));
$goldrate = $q->row(0, 'array');
if(!$goldrate) {
$q = $this->goldrate_model->getGoldrate(null, 'g.gold_id desc', array('limit'=>1, 'offset'=>1));
$tgoldrate = $q->row(0, 'array');
$tgoldrate['date'] = date("Y-m-d H:iConfused");
$tgoldrate['country_id'] = $country->country_id;
unset($tgoldrate['gold_id']);
unset($tgoldrate['country']);
$this->goldrate_model->insert('Goldrate', $tgoldrate);
$q = $this->goldrate_model->getGoldrate(array('g.country_id'=>$country->country_id), 'g.gold_id desc', array('limit'=>1, 'offset'=>0));
$goldrate = $q->row(0, 'array');
}
if($goldrate) $goldrates[$goldrate['country_id']] = $goldrate;
}
/* $gold = $this->gold_model->getGold(NULL,'gold_id desc',array('limit'=>1))->row_array(); */
$data['golds'] = $goldrates;




Theme © iAndrew 2016 - Forum software by © MyBB