Wrox Programmer Forums
BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8
This is the forum to discuss the Wrox book Professional CodeIgniter by Thomas Myer; ISBN: 9780470282458
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 3rd, 2009, 01:08 PM
Registered User
Join Date: Dec 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Search page throwing error


I get this error when searching(I'm on page 126)...

A PHP Error was encountered

Severity: Notice
Message: Undefined variable: results
Filename: views/search.php
Line Number: 5

This is my search.php file contents...

<div id='pleft'>
<h2>Search Results</h2>
if (count($results)) {
    foreach ($results as $key => $list){
        echo "<img src='".$list['thumbnail']."' border='0' align='left' />\n";
        echo "<h4>";
        echo anchor('welcome/product/'.$list['id'],$list['name']);
        echo "</h4>\n";
        echo"<p>".$list['shortdesc']."</p><br style='clear:both'/>";    
    echo "<p>Sorry, no records were found to match your search term.</p>";
All others files are as written in the book and have been double checked with the downloaded files.

Can anyoe shed any light on this?


PS Here are my model view code and controller code...

function search($term){
        $data = array();
        $Q = $this->db->get('products');
        if ($Q->num_rows() > 0){
           foreach ($Q->result_array() as $row){
             $data[] = $row;
        return $data;
function search() {
        if ($this->input->post('term')) {
            $search['results'] = $this->MProducts->search($this->input->post('term'));
        } else {
            redirect('welcome/index', refresh);
        $data['main'] = 'search';
        $data['title'] = "Claudia's Kids | Search Results";
        $data['navlist'] = $this->MCats->getCategoriesNav();
        $this->load->view('template', $data);

Last edited by modelreject; January 3rd, 2009 at 01:10 PM..
Old March 16th, 2009, 10:06 AM
Wrox Author
Join Date: May 2008
Posts: 53
Thanks: 0
Thanked 5 Times in 5 Posts

in your controller function search() change the first line in the IF to:
    $data['results'] = $this->MProducts->search($this->input->post('term'));
Thomas Myer
Author, Professional CodeIgniter
Old April 25th, 2010, 11:12 PM
Registered User
Join Date: Apr 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Thanks

Thank you i was having the same issue, now i can move onto the next one :)

Similar Threads
Thread Thread Starter Forum Replies Last Post
controllers/welcome.php throwing error modelreject BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8 4 March 16th, 2009 10:09 AM
Throwing error back to main thread AgentSmith General .NET 0 April 26th, 2006 09:14 AM
Error catching and throwing - code rjp Access VBA 1 August 25th, 2004 08:32 PM
Error in wrox search Page mahesh_ys@indiatimes.com Forum and Wrox.com Feedback 7 July 19th, 2004 10:17 PM
throwing exceptions...!? jacob ASP.NET 1.0 and 1.1 Basics 3 October 9th, 2003 03:37 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.