Quantcast

Error: Call to a member function find() on a non-object

classic Classic list List threaded Threaded
31 messages Options
12
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Error: Call to a member function find() on a non-object

Russell Brown
Error:  Call to a member function find() on a non-object
File:  c:\wamp\www\cake222\app\Controller\AddressesController.php

I get the error on the $this->set('address_list', $this->Address->find('all')) line below:

Partial listing of my AddressesController file:

<?php
class AddressesController extends AppController {
  var $name = 'addresses';
  
 function index($id = null) {
    $this->set('address_list', $this->Address->find('all'));
  }

I have a controller called AddressesController.php.  I have a Model called Address.php.  The table is called addresses.

I am using Cake 2.2.2 and PHP 5.3.8 and Apache 2.2.21 and MySQL 5.5.16

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Call to a member function find() on a non-object

Ma'moon Al-Akash
Will you also dump your model file contents

On Mon, Oct 15, 2012 at 7:58 PM, Russell Brown <[hidden email]> wrote:
Error:  Call to a member function find() on a non-object
File:  c:\wamp\www\cake222\app\Controller\AddressesController.php

I get the error on the $this->set('address_list', $this->Address->find('all')) line below:

Partial listing of my AddressesController file:

<?php
class AddressesController extends AppController {
  var $name = 'addresses';
  
 function index($id = null) {
    $this->set('address_list', $this->Address->find('all'));
  }

I have a controller called AddressesController.php.  I have a Model called Address.php.  The table is called addresses.

I am using Cake 2.2.2 and PHP 5.3.8 and Apache 2.2.21 and MySQL 5.5.16

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Call to a member function find() on a non-object

lowpass
In reply to this post by Russell Brown
That all looks good to me. Try deleting the files in app/tmp/cache/models

With PHP5.x you don't need the line var $name = 'addresses';

On Mon, Oct 15, 2012 at 7:58 PM, Russell Brown <[hidden email]> wrote:

> Error:  Call to a member function find() on a non-object
> File:  c:\wamp\www\cake222\app\Controller\AddressesController.php
>
> I get the error on the $this->set('address_list',
> $this->Address->find('all')) line below:
>
> Partial listing of my AddressesController file:
>
> <?php
> class AddressesController extends AppController {
>   var $name = 'addresses';
>
>  function index($id = null) {
>     $this->set('address_list', $this->Address->find('all'));
>   }
>
> I have a controller called AddressesController.php.  I have a Model called
> Address.php.  The table is called addresses.
>
> I am using Cake 2.2.2 and PHP 5.3.8 and Apache 2.2.21 and MySQL 5.5.16
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to [hidden email].
> To unsubscribe from this group, send email to
> [hidden email].
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Call to a member function find() on a non-object

Russell Brown
In reply to this post by Ma'moon Al-Akash
Yes, the contents of my Address model is:

<?php
class Address extends AppModel {
  public $name = 'Address';  
}


On Monday, October 15, 2012 7:32:02 PM UTC-5, phpirate wrote:
Will you also dump your model file contents

On Mon, Oct 15, 2012 at 7:58 PM, Russell Brown <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="9BsbIz30zyoJ">ru...@...> wrote:
Error:  Call to a member function find() on a non-object
File:  c:\wamp\www\cake222\app\Controller\AddressesController.php

I get the error on the $this->set('address_list', $this->Address->find('all')) line below:

Partial listing of my AddressesController file:

<?php
class AddressesController extends AppController {
  var $name = 'addresses';
  
 function index($id = null) {
    $this->set('address_list', $this->Address->find('all'));
  }

I have a controller called AddressesController.php.  I have a Model called Address.php.  The table is called addresses.

I am using Cake 2.2.2 and PHP 5.3.8 and Apache 2.2.21 and MySQL 5.5.16

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="9BsbIz30zyoJ">cake...@....
To unsubscribe from this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="9BsbIz30zyoJ">cake-php+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Call to a member function find() on a non-object

Andras Kende
In reply to this post by Russell Brown

try to comment out 
 var $name = 'addresses';
or change it to:  var $name = 'Address';

Andras Kende

On Oct 15, 2012, at 4:58 PM, Russell Brown <[hidden email]> wrote:

Error:  Call to a member function find() on a non-object
File:  c:\wamp\www\cake222\app\Controller\AddressesController.php

I get the error on the $this->set('address_list', $this->Address->find('all')) line below:

Partial listing of my AddressesController file:

<?php
class AddressesController extends AppController {
  var $name = 'addresses';
  
 function index($id = null) {
    $this->set('address_list', $this->Address->find('all'));
  }

I have a controller called AddressesController.php.  I have a Model called Address.php.  The table is called addresses.

I am using Cake 2.2.2 and PHP 5.3.8 and Apache 2.2.21 and MySQL 5.5.16


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Call to a member function find() on a non-object

Russell Brown
In reply to this post by lowpass
I didn't have any other files in app/tmp/cache/models.  I have an "empty" file though.



On Monday, October 15, 2012 7:38:32 PM UTC-5, cricket wrote:
That all looks good to me. Try deleting the files in app/tmp/cache/models

With PHP5.x you don't need the line var $name = 'addresses';

On Mon, Oct 15, 2012 at 7:58 PM, Russell Brown <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="CuzbwI5dV4oJ">ru...@...> wrote:

> Error:  Call to a member function find() on a non-object
> File:  c:\wamp\www\cake222\app\Controller\AddressesController.php
>
> I get the error on the $this->set('address_list',
> $this->Address->find('all')) line below:
>
> Partial listing of my AddressesController file:
>
> <?php
> class AddressesController extends AppController {
>   var $name = 'addresses';
>
>  function index($id = null) {
>     $this->set('address_list', $this->Address->find('all'));
>   }
>
> I have a controller called AddressesController.php.  I have a Model called
> Address.php.  The table is called addresses.
>
> I am using Cake 2.2.2 and PHP 5.3.8 and Apache 2.2.21 and MySQL 5.5.16
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="CuzbwI5dV4oJ">cake...@....
> To unsubscribe from this group, send email to
> <a href="javascript:" target="_blank" gdf-obfuscated-mailto="CuzbwI5dV4oJ">cake-php+u...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Call to a member function find() on a non-object

Russell Brown
In reply to this post by lowpass
Yes I read about the var $name = 'addresses'; line but I also saw that it doesn't hurt to have it in there and should actually read:

public $name = 'addresses';

I have tried it with and without the line though and I still get the same error.


On Monday, October 15, 2012 7:38:32 PM UTC-5, cricket wrote:
That all looks good to me. Try deleting the files in app/tmp/cache/models

With PHP5.x you don't need the line var $name = 'addresses';

On Mon, Oct 15, 2012 at 7:58 PM, Russell Brown <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="CuzbwI5dV4oJ">ru...@...> wrote:

> Error:  Call to a member function find() on a non-object
> File:  c:\wamp\www\cake222\app\Controller\AddressesController.php
>
> I get the error on the $this->set('address_list',
> $this->Address->find('all')) line below:
>
> Partial listing of my AddressesController file:
>
> <?php
> class AddressesController extends AppController {
>   var $name = 'addresses';
>
>  function index($id = null) {
>     $this->set('address_list', $this->Address->find('all'));
>   }
>
> I have a controller called AddressesController.php.  I have a Model called
> Address.php.  The table is called addresses.
>
> I am using Cake 2.2.2 and PHP 5.3.8 and Apache 2.2.21 and MySQL 5.5.16
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="CuzbwI5dV4oJ">cake...@....
> To unsubscribe from this group, send email to
> <a href="javascript:" target="_blank" gdf-obfuscated-mailto="CuzbwI5dV4oJ">cake-php+u...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Call to a member function find() on a non-object

Russell Brown
In reply to this post by Andras Kende
Ok.  Yes, I did try both commenting it out, deleting it and changing var to public.  It didn't get rid of the error though.

On Monday, October 15, 2012 8:03:38 PM UTC-5, Andras Kende wrote:

try to comment out 
 var $name = 'addresses';
or change it to:  var $name = 'Address';

Andras Kende

On Oct 15, 2012, at 4:58 PM, Russell Brown <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="jWQLRMtzRcsJ">ru...@...> wrote:

Error:  Call to a member function find() on a non-object
File:  c:\wamp\www\cake222\app\Controller\AddressesController.php

I get the error on the $this->set('address_list', $this->Address->find('all')) line below:

Partial listing of my AddressesController file:

<?php
class AddressesController extends AppController {
  var $name = 'addresses';
  
 function index($id = null) {
    $this->set('address_list', $this->Address->find('all'));
  }

I have a controller called AddressesController.php.  I have a Model called Address.php.  The table is called addresses.

I am using Cake 2.2.2 and PHP 5.3.8 and Apache 2.2.21 and MySQL 5.5.16


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="jWQLRMtzRcsJ">cake...@....
To unsubscribe from this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="jWQLRMtzRcsJ">cake-php+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Call to a member function find() on a non-object

Russell Brown
In reply to this post by Russell Brown
Here is the error in the error.log:

2012-10-16 01:16:44 Error: Fatal Error (1): Call to a member function find() on a non-object in [C:\wamp\www\cake222\app\Controller\AddressesController.php, line 9]
2012-10-16 01:16:44 Error: [FatalErrorException] Call to a member function find() on a non-object
#0 C:\wamp\www\cake222\lib\Cake\Error\ErrorHandler.php(162): ErrorHandler::handleFatalError(1, 'Call to a membe...', 'C:\wamp\www\cak...', 9)
#1 [internal function]: ErrorHandler::handleError(1, 'Call to a membe...', 'C:\wamp\www\cak...', 9, Array)
#2 C:\wamp\www\cake222\lib\Cake\Core\App.php(926): call_user_func('ErrorHandler::h...', 1, 'Call to a membe...', 'C:\wamp\www\cak...', 9, Array)
#3 C:\wamp\www\cake222\lib\Cake\Core\App.php(899): App::_checkFatalError()
#4 [internal function]: App::shutdown()
#5 {main}





On Monday, October 15, 2012 6:58:52 PM UTC-5, Russell Brown wrote:
Error:  Call to a member function find() on a non-object
File:  c:\wamp\www\cake222\app\Controller\AddressesController.php

I get the error on the $this->set('address_list', $this->Address->find('all')) line below:

Partial listing of my AddressesController file:

<?php
class AddressesController extends AppController {
  var $name = 'addresses';
  
 function index($id = null) {
    $this->set('address_list', $this->Address->find('all'));
  }

I have a controller called AddressesController.php.  I have a Model called Address.php.  The table is called addresses.

I am using Cake 2.2.2 and PHP 5.3.8 and Apache 2.2.21 and MySQL 5.5.16

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Call to a member function find() on a non-object

Russell Brown
In reply to this post by Russell Brown
Here is my index.ctp view file in the View\Addresses folder:

<?php
echo $this->Html->link('Add New Address', array('action'=>'add'));
?>
<table>
  <tr>
 <th>Id</th>
 <th>First Name</th>
 <th>Last Name</th>
 <th>Email</th>
 <th>Phone</th>
 <th>Address</th>
 <th>Options</th>
  </tr>
  
<?php
  foreach ( $address_list as $line ) {
  $address = $line['Address'];
echo
'<tr>'.
'<td>'.$address['id'].'</td>'.
'<td>'.$this->Html->link($address['first_name'], array('action'=>'view', 'id'=>$address['id'])).'</td>'.
'<td>'.$address['last_name'].'</td>'.
'<td>'.$address['email'].'</td>'.
'<td>'.$address['phone'].'</td>'.
'<td>'.$address['address'].'</td>'.
'<td>'.$this->Html->link('edit', array('action'=>'edit', 'id'=>$address['id'])).' '.

$this->Html->link('delete', array('action'=>'delete', 'id'=>$address['id'])).'</td>'.
'</tr>';

  };
?>
</table>


On Monday, October 15, 2012 6:58:52 PM UTC-5, Russell Brown wrote:
Error:  Call to a member function find() on a non-object
File:  c:\wamp\www\cake222\app\Controller\AddressesController.php

I get the error on the $this->set('address_list', $this->Address->find('all')) line below:

Partial listing of my AddressesController file:

<?php
class AddressesController extends AppController {
  var $name = 'addresses';
  
 function index($id = null) {
    $this->set('address_list', $this->Address->find('all'));
  }

I have a controller called AddressesController.php.  I have a Model called Address.php.  The table is called addresses.

I am using Cake 2.2.2 and PHP 5.3.8 and Apache 2.2.21 and MySQL 5.5.16

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Call to a member function find() on a non-object

Wallace Cardoso Colaco Ricardo
Try to debug what objects(Models) are being loaded...

Doing so you will know for sure the name of the instance Address.

Put this before your find:

debug($this);

On Oct 15, 2012, at 9:23 PM, Russell Brown wrote:

Here is my index.ctp view file in the View\Addresses folder:

<?php
echo $this->Html->link('Add New Address', array('action'=>'add'));
?>
<table>
  <tr>
 <th>Id</th>
 <th>First Name</th>
 <th>Last Name</th>
 <th>Email</th>
 <th>Phone</th>
 <th>Address</th>
 <th>Options</th>
  </tr>
  
<?php
  foreach ( $address_list as $line ) {
  $address = $line['Address'];
echo
'<tr>'.
'<td>'.$address['id'].'</td>'.
'<td>'.$this->Html->link($address['first_name'], array('action'=>'view', 'id'=>$address['id'])).'</td>'.
'<td>'.$address['last_name'].'</td>'.
'<td>'.$address['email'].'</td>'.
'<td>'.$address['phone'].'</td>'.
'<td>'.$address['address'].'</td>'.
'<td>'.$this->Html->link('edit', array('action'=>'edit', 'id'=>$address['id'])).' '.

$this->Html->link('delete', array('action'=>'delete', 'id'=>$address['id'])).'</td>'.
'</tr>';

  };
?>
</table>


On Monday, October 15, 2012 6:58:52 PM UTC-5, Russell Brown wrote:
Error:  Call to a member function find() on a non-object
File:  c:\wamp\www\cake222\app\Controller\AddressesController.php

I get the error on the $this->set('address_list', $this->Address->find('all')) line below:

Partial listing of my AddressesController file:

<?php
class AddressesController extends AppController {
  var $name = 'addresses';
  
 function index($id = null) {
    $this->set('address_list', $this->Address->find('all'));
  }

I have a controller called AddressesController.php.  I have a Model called Address.php.  The table is called addresses.

I am using Cake 2.2.2 and PHP 5.3.8 and Apache 2.2.21 and MySQL 5.5.16


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Call to a member function find() on a non-object

Russell Brown
In reply to this post by Russell Brown
Here is what the routes.php file looks like:

<?php
  Router::connect('/the-book', array('controller' => 'addresses', 'action' => 'index'));
?>


On Monday, October 15, 2012 6:58:52 PM UTC-5, Russell Brown wrote:
Error:  Call to a member function find() on a non-object
File:  c:\wamp\www\cake222\app\Controller\AddressesController.php

I get the error on the $this->set('address_list', $this->Address->find('all')) line below:

Partial listing of my AddressesController file:

<?php
class AddressesController extends AppController {
  var $name = 'addresses';
  
 function index($id = null) {
    $this->set('address_list', $this->Address->find('all'));
  }

I have a controller called AddressesController.php.  I have a Model called Address.php.  The table is called addresses.

I am using Cake 2.2.2 and PHP 5.3.8 and Apache 2.2.21 and MySQL 5.5.16

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Call to a member function find() on a non-object

PlanoCoder
In reply to this post by Russell Brown
Pull your Array

you may need to change

'<td>'.$address['id'].'</td>'.

to

'<td>'.$address[0]['id'].'</td>'.

or something like that

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Call to a member function find() on a non-object

Russell Brown
Ok.  I changed the index.ctp as shown in the pertinent section of code as follows (but I still get the same error):

 foreach ( $address_list as $line ) {
  $address = $line['Address'];
echo
'<tr>'.
'<td>'.$address[0]['id'].'</td>'.
/* '<td>'.$this->Html->link($address['first_name'], array('action'=>'view', 'id'=>$address['id'])).'</td>'.
*/

'<td>'.$this->Html->link($address['first_name'], array('action'=>'view', 'id'=>$address[0]['id'])).'</td>'.
'<td>'.$address['last_name'].'</td>'.
'<td>'.$address['email'].'</td>'.
'<td>'.$address['phone'].'</td>'.
'<td>'.$address['address'].'</td>'.
'<td>'.$this->Html->link('edit', array('action'=>'edit', 'id'=>$address[0]['id'])).' '.

$this->Html->link('delete', array('action'=>'delete', 'id'=>$address[0]['id'])).'</td>'.



On Wednesday, October 17, 2012 9:27:07 AM UTC-5, PlanoCoder wrote:
Pull your Array

you may need to change

'<td>'.$address['id'].'</td>'.

to

'<td>'.$address[0]['id'].'</td>'.

or something like that

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Call to a member function find() on a non-object

Jonathan Sundquist
The error has nothing to do with your view.  It will have to do with either your model or your controller.  As people have previously stated can you do a debug($this) before and after your find? It will show if the Address model is actually loaded or not.  If its not loaded then your find method will for sure not work.

On Thu, Oct 18, 2012 at 12:09 PM, Russell Brown <[hidden email]> wrote:
Ok.  I changed the index.ctp as shown in the pertinent section of code as follows (but I still get the same error):

 foreach ( $address_list as $line ) {
  $address = $line['Address'];
echo
'<tr>'.
'<td>'.$address[0]['id'].'</td>'.
/* '<td>'.$this->Html->link($address['first_name'], array('action'=>'view', 'id'=>$address['id'])).'</td>'.
*/

'<td>'.$this->Html->link($address['first_name'], array('action'=>'view', 'id'=>$address[0]['id'])).'</td>'.
'<td>'.$address['last_name'].'</td>'.
'<td>'.$address['email'].'</td>'.
'<td>'.$address['phone'].'</td>'.
'<td>'.$address['address'].'</td>'.
'<td>'.$this->Html->link('edit', array('action'=>'edit', 'id'=>$address[0]['id'])).' '.

$this->Html->link('delete', array('action'=>'delete', 'id'=>$address[0]['id'])).'</td>'.



On Wednesday, October 17, 2012 9:27:07 AM UTC-5, PlanoCoder wrote:
Pull your Array

you may need to change

'<td>'.$address['id'].'</td>'.

to

'<td>'.$address[0]['id'].'</td>'.

or something like that

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Call to a member function find() on a non-object

Russell Brown
I can't get debug($this) to work in Cake 2.2.2.

It may be different in Cake 2.2.2 but I haven't been able to figure it out.  I have installed the DebugKit plugin.

On Thursday, October 18, 2012 12:36:00 PM UTC-5, jsundquist wrote:
The error has nothing to do with your view.  It will have to do with either your model or your controller.  As people have previously stated can you do a debug($this) before and after your find? It will show if the Address model is actually loaded or not.  If its not loaded then your find method will for sure not work.

On Thu, Oct 18, 2012 at 12:09 PM, Russell Brown <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="C_I9iAr13mUJ">ru...@...> wrote:
Ok.  I changed the index.ctp as shown in the pertinent section of code as follows (but I still get the same error):

 foreach ( $address_list as $line ) {
  $address = $line['Address'];
echo
'<tr>'.
'<td>'.$address[0]['id'].'</td>'.
/* '<td>'.$this->Html->link($address['first_name'], array('action'=>'view', 'id'=>$address['id'])).'</td>'.
*/

'<td>'.$this->Html->link($address['first_name'], array('action'=>'view', 'id'=>$address[0]['id'])).'</td>'.
'<td>'.$address['last_name'].'</td>'.
'<td>'.$address['email'].'</td>'.
'<td>'.$address['phone'].'</td>'.
'<td>'.$address['address'].'</td>'.
'<td>'.$this->Html->link('edit', array('action'=>'edit', 'id'=>$address[0]['id'])).' '.

$this->Html->link('delete', array('action'=>'delete', 'id'=>$address[0]['id'])).'</td>'.



On Wednesday, October 17, 2012 9:27:07 AM UTC-5, PlanoCoder wrote:
Pull your Array

you may need to change

'<td>'.$address['id'].'</td>'.

to

'<td>'.$address[0]['id'].'</td>'.

or something like that

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="C_I9iAr13mUJ">cake...@....
To unsubscribe from this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="C_I9iAr13mUJ">cake-php+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Call to a member function find() on a non-object

Russell Brown
In reply to this post by Wallace Cardoso Colaco Ricardo
When I put debug($this); in the file, however I get a syntax error on that line.

I am using Cake 2.2.2 and I have installed the DebugKit too.



On Monday, October 15, 2012 8:27:58 PM UTC-5, Wallace Cardoso Colaço Ricardo wrote:
Try to debug what objects(Models) are being loaded...

Doing so you will know for sure the name of the instance Address.

Put this before your find:

debug($this);

On Oct 15, 2012, at 9:23 PM, Russell Brown wrote:

Here is my index.ctp view file in the View\Addresses folder:

<?php
echo $this->Html->link('Add New Address', array('action'=>'add'));
?>
<table>
  <tr>
 <th>Id</th>
 <th>First Name</th>
 <th>Last Name</th>
 <th>Email</th>
 <th>Phone</th>
 <th>Address</th>
 <th>Options</th>
  </tr>
  
<?php
  foreach ( $address_list as $line ) {
  $address = $line['Address'];
echo
'<tr>'.
'<td>'.$address['id'].'</td>'.
'<td>'.$this->Html->link($address['first_name'], array('action'=>'view', 'id'=>$address['id'])).'</td>'.
'<td>'.$address['last_name'].'</td>'.
'<td>'.$address['email'].'</td>'.
'<td>'.$address['phone'].'</td>'.
'<td>'.$address['address'].'</td>'.
'<td>'.$this->Html->link('edit', array('action'=>'edit', 'id'=>$address['id'])).' '.

$this->Html->link('delete', array('action'=>'delete', 'id'=>$address['id'])).'</td>'.
'</tr>';

  };
?>
</table>


On Monday, October 15, 2012 6:58:52 PM UTC-5, Russell Brown wrote:
Error:  Call to a member function find() on a non-object
File:  c:\wamp\www\cake222\app\Controller\AddressesController.php

I get the error on the $this->set('address_list', $this->Address->find('all')) line below:

Partial listing of my AddressesController file:

<?php
class AddressesController extends AppController {
  var $name = 'addresses';
  
 function index($id = null) {
    $this->set('address_list', $this->Address->find('all'));
  }

I have a controller called AddressesController.php.  I have a Model called Address.php.  The table is called addresses.

I am using Cake 2.2.2 and PHP 5.3.8 and Apache 2.2.21 and MySQL 5.5.16


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="DdU8RLRDkuoJ">cake...@....
To unsubscribe from this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="DdU8RLRDkuoJ">cake-php+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Call to a member function find() on a non-object

Jonathan Sundquist

Sorry. Do a var_dump($this)

- "The cold winds are rising"

On Oct 18, 2012 3:29 PM, "Russell Brown" <[hidden email]> wrote:
When I put debug($this); in the file, however I get a syntax error on that line.

I am using Cake 2.2.2 and I have installed the DebugKit too.



On Monday, October 15, 2012 8:27:58 PM UTC-5, Wallace Cardoso Colaço Ricardo wrote:
Try to debug what objects(Models) are being loaded...

Doing so you will know for sure the name of the instance Address.

Put this before your find:

debug($this);

On Oct 15, 2012, at 9:23 PM, Russell Brown wrote:

Here is my index.ctp view file in the View\Addresses folder:

<?php
echo $this->Html->link('Add New Address', array('action'=>'add'));
?>
<table>
  <tr>
 <th>Id</th>
 <th>First Name</th>
 <th>Last Name</th>
 <th>Email</th>
 <th>Phone</th>
 <th>Address</th>
 <th>Options</th>
  </tr>
  
<?php
  foreach ( $address_list as $line ) {
  $address = $line['Address'];
echo
'<tr>'.
'<td>'.$address['id'].'</td>'.
'<td>'.$this->Html->link($address['first_name'], array('action'=>'view', 'id'=>$address['id'])).'</td>'.
'<td>'.$address['last_name'].'</td>'.
'<td>'.$address['email'].'</td>'.
'<td>'.$address['phone'].'</td>'.
'<td>'.$address['address'].'</td>'.
'<td>'.$this->Html->link('edit', array('action'=>'edit', 'id'=>$address['id'])).' '.

$this->Html->link('delete', array('action'=>'delete', 'id'=>$address['id'])).'</td>'.
'</tr>';

  };
?>
</table>


On Monday, October 15, 2012 6:58:52 PM UTC-5, Russell Brown wrote:
Error:  Call to a member function find() on a non-object
File:  c:\wamp\www\cake222\app\Controller\AddressesController.php

I get the error on the $this->set('address_list', $this->Address->find('all')) line below:

Partial listing of my AddressesController file:

<?php
class AddressesController extends AppController {
  var $name = 'addresses';
  
 function index($id = null) {
    $this->set('address_list', $this->Address->find('all'));
  }

I have a controller called AddressesController.php.  I have a Model called Address.php.  The table is called addresses.

I am using Cake 2.2.2 and PHP 5.3.8 and Apache 2.2.21 and MySQL 5.5.16


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to cake-php+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Call to a member function find() on a non-object

lowpass
In reply to this post by Russell Brown
Any other info on what the syntax error is? I'm beginning to think
something is really borked with your install.

On Thu, Oct 18, 2012 at 4:28 PM, Russell Brown <[hidden email]> wrote:

> When I put debug($this); in the file, however I get a syntax error on that
> line.
>
> I am using Cake 2.2.2 and I have installed the DebugKit too.
>
>
>
> On Monday, October 15, 2012 8:27:58 PM UTC-5, Wallace Cardoso Colaço Ricardo
> wrote:
>>
>> Try to debug what objects(Models) are being loaded...
>>
>> Doing so you will know for sure the name of the instance Address.
>>
>> Put this before your find:
>>
>> debug($this);
>>
>> On Oct 15, 2012, at 9:23 PM, Russell Brown wrote:
>>
>> Here is my index.ctp view file in the View\Addresses folder:
>>
>> <?php
>> echo $this->Html->link('Add New Address', array('action'=>'add'));
>> ?>
>> <table>
>>   <tr>
>>  <th>Id</th>
>>  <th>First Name</th>
>>  <th>Last Name</th>
>>  <th>Email</th>
>>  <th>Phone</th>
>>  <th>Address</th>
>>  <th>Options</th>
>>   </tr>
>>
>> <?php
>>   foreach ( $address_list as $line ) {
>>   $address = $line['Address'];
>> echo
>> '<tr>'.
>> '<td>'.$address['id'].'</td>'.
>> '<td>'.$this->Html->link($address['first_name'], array('action'=>'view',
>> 'id'=>$address['id'])).'</td>'.
>> '<td>'.$address['last_name'].'</td>'.
>> '<td>'.$address['email'].'</td>'.
>> '<td>'.$address['phone'].'</td>'.
>> '<td>'.$address['address'].'</td>'.
>> '<td>'.$this->Html->link('edit', array('action'=>'edit',
>> 'id'=>$address['id'])).' '.
>>
>> $this->Html->link('delete', array('action'=>'delete',
>> 'id'=>$address['id'])).'</td>'.
>> '</tr>';
>>
>>   };
>> ?>
>> </table>
>>
>>
>> On Monday, October 15, 2012 6:58:52 PM UTC-5, Russell Brown wrote:
>>>
>>> Error:  Call to a member function find() on a non-object
>>> File:  c:\wamp\www\cake222\app\Controller\AddressesController.php
>>>
>>> I get the error on the $this->set('address_list',
>>> $this->Address->find('all')) line below:
>>>
>>> Partial listing of my AddressesController file:
>>>
>>> <?php
>>> class AddressesController extends AppController {
>>>   var $name = 'addresses';
>>>
>>>  function index($id = null) {
>>>     $this->set('address_list', $this->Address->find('all'));
>>>   }
>>>
>>> I have a controller called AddressesController.php.  I have a Model
>>> called Address.php.  The table is called addresses.
>>>
>>> I am using Cake 2.2.2 and PHP 5.3.8 and Apache 2.2.21 and MySQL 5.5.16
>>>
>>
>> --
>> Like Us on FaceBook https://www.facebook.com/CakePHP
>> Find us on Twitter http://twitter.com/CakePHP
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "CakePHP" group.
>> To post to this group, send email to [hidden email].
>> To unsubscribe from this group, send email to
>> [hidden email].
>>
>> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>>
>>
>>
>>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to [hidden email].
> To unsubscribe from this group, send email to
> [hidden email].
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Call to a member function find() on a non-object

Russell Brown
Yes.  I did a clean install and still get the error.

I get the DebugKit toolbar -it works fine.

For some reason I can't just type debug($this); before and after the variable I want to check.  Still gives me a syntax error.

On Thursday, October 18, 2012 3:50:23 PM UTC-5, cricket wrote:
Any other info on what the syntax error is? I'm beginning to think
something is really borked with your install.

On Thu, Oct 18, 2012 at 4:28 PM, Russell Brown <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="svcAJNs0OdoJ">ru...@...> wrote:

> When I put debug($this); in the file, however I get a syntax error on that
> line.
>
> I am using Cake 2.2.2 and I have installed the DebugKit too.
>
>
>
> On Monday, October 15, 2012 8:27:58 PM UTC-5, Wallace Cardoso Colaço Ricardo
> wrote:
>>
>> Try to debug what objects(Models) are being loaded...
>>
>> Doing so you will know for sure the name of the instance Address.
>>
>> Put this before your find:
>>
>> debug($this);
>>
>> On Oct 15, 2012, at 9:23 PM, Russell Brown wrote:
>>
>> Here is my index.ctp view file in the View\Addresses folder:
>>
>> <?php
>> echo $this->Html->link('Add New Address', array('action'=>'add'));
>> ?>
>> <table>
>>   <tr>
>>  <th>Id</th>
>>  <th>First Name</th>
>>  <th>Last Name</th>
>>  <th>Email</th>
>>  <th>Phone</th>
>>  <th>Address</th>
>>  <th>Options</th>
>>   </tr>
>>
>> <?php
>>   foreach ( $address_list as $line ) {
>>   $address = $line['Address'];
>> echo
>> '<tr>'.
>> '<td>'.$address['id'].'</td>'.
>> '<td>'.$this->Html->link($address['first_name'], array('action'=>'view',
>> 'id'=>$address['id'])).'</td>'.
>> '<td>'.$address['last_name'].'</td>'.
>> '<td>'.$address['email'].'</td>'.
>> '<td>'.$address['phone'].'</td>'.
>> '<td>'.$address['address'].'</td>'.
>> '<td>'.$this->Html->link('edit', array('action'=>'edit',
>> 'id'=>$address['id'])).' '.
>>
>> $this->Html->link('delete', array('action'=>'delete',
>> 'id'=>$address['id'])).'</td>'.
>> '</tr>';
>>
>>   };
>> ?>
>> </table>
>>
>>
>> On Monday, October 15, 2012 6:58:52 PM UTC-5, Russell Brown wrote:
>>>
>>> Error:  Call to a member function find() on a non-object
>>> File:  c:\wamp\www\cake222\app\Controller\AddressesController.php
>>>
>>> I get the error on the $this->set('address_list',
>>> $this->Address->find('all')) line below:
>>>
>>> Partial listing of my AddressesController file:
>>>
>>> <?php
>>> class AddressesController extends AppController {
>>>   var $name = 'addresses';
>>>
>>>  function index($id = null) {
>>>     $this->set('address_list', $this->Address->find('all'));
>>>   }
>>>
>>> I have a controller called AddressesController.php.  I have a Model
>>> called Address.php.  The table is called addresses.
>>>
>>> I am using Cake 2.2.2 and PHP 5.3.8 and Apache 2.2.21 and MySQL 5.5.16
>>>
>>
>> --
>> Like Us on FaceBook https://www.facebook.com/CakePHP
>> Find us on Twitter http://twitter.com/CakePHP
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "CakePHP" group.
>> To post to this group, send email to [hidden email].
>> To unsubscribe from this group, send email to
>> [hidden email].
>>
>> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>>
>>
>>
>>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="svcAJNs0OdoJ">cake...@....
> To unsubscribe from this group, send email to
> <a href="javascript:" target="_blank" gdf-obfuscated-mailto="svcAJNs0OdoJ">cake-php+u...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 
12
Loading...