[eluser]awpti[/eluser]
Error with mini-description is here:
http://www.awpti.org/links/linkout/3/
Model:
Code:
class Linksmodel extends Model {
function Linksmodel() {
parent::Model();
}
function get_top() {
$links = $this->db->query('SELECT link_clicks, link_name, link_id FROM awLinks ORDER BY link_clicks DESC LIMIT 5');
return $links->result();
}
function countup_and_get_link($link_id) {
if(ctype_digit($link_id)) {
$this->db->query('UPDATE awLinks SET link_clicks = (link_clicks + 1) WHERE link_id = '.$link_id);
$link = $this->db->query('SELECT link_url FROM awLinks WHERE link_id = '.$link_id);
return $link->result();
} else {
return FALSE;
}
}
}
And the controller:
Code:
class Links extends Controller {
public $awTitle = 'awpti.org - where geeks roam free! (Link Catalog)';
public $awHeader = 'awpti.org';
function Links() {
parent::Controller();
$this->view->set('Title', $this->awTitle);
$this->view->set('Title', $this->awHeader);
$this->load->model('linksmodel', 'links', TRUE);
$this->view->part('template_top', 'common/header.php');
$this->view->part('template_bottom', 'common/footer.php');
}
function index() {
$links = $this->links->get_top();
foreach($links as $link) {
echo '<a href="/links/linkout/'.$link->link_id.'">'.$link->link_name.' ('.$link->link_clicks.')</a><br />';
}
}
function linkout() {
if(ctype_digit($this->uri->segment(3)) ) {
$link = $this->links->countup_and_get_link($this->uri->segment(3));
print_r($link);
echo '<br />This error is from "print $link->link_url", which looks right above..<br />';
print $link->link_url;
//redirect_outside($link->link_url);
} else {
redirect('/errors/linkout/');
}
}
}
I'm stumped. Do I need to do some goofy loop action for a single returned entry?