Thursday, October 18, 2012

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

I can connect to it via phpMyAdmin and see the databases and tables.  Is that what you mean by connecting to it directly?

I suspect my database config must be the problem yes.

In the config folder under the app I have my database.php file setup.  I wonder if there is another database config I should be looking at?

I have another database.php file setup exactly the same way except for the database name and it works fine.  I can see the app in the browser no problem.





On Thursday, October 18, 2012 6:13:47 PM UTC-5, jsundquist wrote:
Did you set up your database config correctly?  Try connecting to it directly to see if your database is up and your connection information is correct.

On Thu, Oct 18, 2012 at 6:06 PM, Russell Brown <ru...@russsoftware.com> wrote:
It does give me the line number.  However, I just noticed that SQL Logs says "Warning - No active database connection" 

When I look at variables I see:  $request->data(empty)

Somehow I am not connected to the database and/or table.

On Thursday, October 18, 2012 5:47:21 PM UTC-5, phpirate wrote:
Does it say at what line the error occurs? What does your web server's error log say? 

On Thu, Oct 18, 2012 at 6:14 PM, Russell Brown <ru...@russsoftware.com> wrote:
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 <ru...@russsoftware.com> 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 cake...@googlegroups.com.
>> 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 cake...@googlegroups.com.
> 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 cake...@googlegroups.com.
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 cake...@googlegroups.com.
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 cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: