An internal error occured in cakephp - php

I have a controller name ReminderController from which I wanna call admin_index.ctp.
class ReminderController extends AppController {
public function admin_index(){
$this->paginate=array('limit' =>'10');
$this->set('news', $this->paginate('Reminder'));
}
When I call view name admin_index from a controller I found an internal error has been occurred... please help me out from this problem.........

I'm not familiar with cakephp, but according to me error is in below 2 lines:
$this->paginate=array('limit' =>'10');
$this->set('news', $this->paginate('Reminder'));
Because, in the first line you are assigning an array to $this->paginate. But in the second line you are calling it as a function.

Related

Laravel Controller saying undefined Request, Any error here?

I am developing a laravel project but some part of my codes is returning an error of undefined request
Seems like i forgot something or ..
Here is a snip
Of my codes
the problem is with how you defined Request Parameter in your function, It should be like
public function insertrecord(Request $request) {}
Now you can proceed... Hope this helps..

Cakephp How to access AppController function in ctp file?

I am unable to access AppController.php function in my ctp file.
Please check my code:
AppController
public function commonEmotions($text=null){
$this->loadModel("Sticker");
$this->loadModel("Smiley");
//Smiley
$getSmiley=$this->Smiley->find('all',array('fields'=>array('Smiley.image','Smiley.symbol')));
$emotions=$this->Custom->parseEmotions($text,$getSmiley);
//Sticker
$getSticker = $this->Sticker->find('all',array('fields'=>array('Sticker.uniq_id','Sticker.image')));
$message=$this->Custom->parseStickers($emotions,$getSticker);
return $message;
}
View/Messages/news_feed.ctp
echo $this->requestAction('/app/commonEmotions/'.$getNewsFeed['News_feed']['news']);
When i running my code i am getting fllowing error
Notice (8): Undefined index: News_feed [APP\View\Messages\news_feed.ctp, line 188]
Warning (2): Missing argument 1 for AppController::commonEmotions() [APP\Controller\AppController.php, line 51]
Instead of
echo $this->requestAction('/app/commonEmotions/'.$getNewsFeed['News_feed']['news']);
Do the request to any of your controllers instead of calling the app controller directly
echo $this->requestAction('/Smiley/commonEmotions/'.$getNewsFeed['News_feed']['news']);
As all your controllers inherit the method from the app controller

Error: <Composite Controller> could not be found

I bake my table user_routes and CakePHP create class Controllers with name UserRoutesController.php, but, i call the link 'http://[server]/userroutes' and the follow error that show to me:
Error: UserroutesController could not be found.
Error: Create the class UserroutesController below in file: app/Controller/UserroutesController.php
<?php
class UserroutesController extends AppController {
}
Notice: If you want to customize this error message, create app/View/Errors/missing_controller.ctp
I checked all convention names and .htaccess and that's all ok.
best regards,
Marcos
My fault!
I was accessing the URL as
http://[server]/userroutes
but the correct thing
http://[server]/user_routes
Marcos

How to load two models in the same controller with CodeIgniter?

I've been searching on Internet and on stackoverflow, but i didn't find a solution, or it wasn't the same problem.
I need to load two models in the same controller, and in the same function. One is "model_membre" and the other "model_annonce". It's the name of the class, the file, and the object.
Individually, they work very good, i can access to properties and methods, but when I'm loading the two models, I can't access to the second, regardless of how I load it (autoload, $this->load->model('model_name'), $this->load->model('model_name', 'object_name')).
I simplified to a "test" controller, to see if it was not another part of my code that made the problem :
public function index()
{
$this->load->model('model_membre', 'membre');
$this->load->model('model_annonce', 'annonce');
$liste = $this->annonce->listerEspeces();
$membre = $this->membre->obtenirMembre(1);
}
I tried to changer the order, and the 2nd loaded never works. I get this message :
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Test::$annonce
Filename: controllers/test.php
Line Number: 15
Fatal error: Call to a member function listerEspeces() on a non-object in /homez.604/animalix/beta/application/controllers/test.php on line 15
Please try the following way...
public function index()
{
$this->load->model(array('membre','annonce'));
$liste = $this->annonce->listerEspeces();
$membre = $this->membre->obtenirMembre(1);
}
The models should extend CI_Model and not CI_Controller! This was the source of the problem.

Testing a form with missing elements gives me an error with is ErrorController.php

I'm doing some testing to my login form but I notice that If I dont send all the expected parameters, I get this error:
Fatal error: Call to a member function hasResource() on a non-object in C:\demo\application\controllers\ErrorController.php on line 47
for example this test code gives me error:
public function testLoginPage ()
{
$this->request->setMethod('POST')->setPost(
array('username' => 'foobar');
$this->dispatch('/usuario/login');
}
But if I send all the elements everything works as expected:
public function testLoginPage ()
{
$this->request->setMethod('POST')->setPost(
array('username' => 'foobar','password' => 'secret');
$this->dispatch('/usuario/login');
}
Is this normal? I dont understard why I get an error on ErrorController.php, where is the connection?
(I thought that maybe is something that not loading, but why is it working when all elemnts are?)
Any help understanding this will be appreciated.
Thanks
Update:
I just change to an incorrect password for db database in the application.ini and that gives me the same error. Now I dont even think is the form but maybe some call at the bootstart that is depending to the Zend_Auth identity. But what means that Fatal error: Call to a member function hasResource() on a non-object? how to load that object?
Read the error message you get. You're calling hasResource() on a non-object in ErrorController.php. Your error controller is broken, but that's not really the issue here.
The issue is that there's an exception being thrown somewhere (possibly in your form, bootstrap, or anywhere really) which triggers the error controller. Fix or disable the error handler to get the exception message and stack trace to find out your problem.
To disable the error handler
$front = Zend_Controller_Front::getInstance();
$front->setParam('noErrorHandler', true);

Categories