500 Internal server error in CRUD with Firebird - codeigniter

I have installed CRUD application in my CI.I am using Firebird database.The connection is fine while i am testing :
$res= $this->db->query('SELECT * FROM ADMIN_USER');
var_dump($res->row());
this is returning result.
but while i an using crud function:
public function admin()
{
try{
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('ADMIN_USER');
$crud->columns('USERNAME','PASSWORD');
$output = $crud->render();
var_dump($output);
$this->_example_output($output);
}catch(Exception $e){
show_error($e->getMessage().' --- '.$e->getTraceAsString());
}
}
no result is coming..and "500Internal Server Error" is showing in firebug..
The actual error shown:
An Error Was Encountered
The table name does not exist. Please check you database and try again. ---
#0 C:\wamp\www\anuncio\application\libraries\Grocery_CRUD.php(4420): Grocery_CRUD->get_table()
#1 C:\wamp\www\anuncio\application\libraries\Grocery_CRUD.php(4436): Grocery_CRUD->pre_render()
#2 C:\wamp\www\anuncio\application\controllers\examples.php(27): Grocery_CRUD->render()
#3 [internal function]: Examples->admin()
#4 C:\wamp\www\anuncio\system\core\CodeIgniter.php(359): call_user_func_array(Array, Array)
#5 C:\wamp\www\anuncio\index.php(202): require_once('C:\\wamp\\www\\anu...')
#6 {main}
I am new in CI, grocery CRUD and Firebird..Cant solve this error.Please help me.

Quite easy, your table does not exist. To be more specific, the table ADMIN_USER does not exist.

Related

Livewire multiple issues with file upload

What seems to be the problem:
6 exceptions being logged with each upload (although the file gets uploaded)
Steps to Reproduce:
Follow the documentation page to create simple file upload
Try uploading a file
Check laravel log file
Laravel version: 5.7
Livewire version: 1.3.5
Laravel log sample:
[2021-01-21 11:05:07] local.ERROR: {"userId":47,"email":"user#example.com","exception":"[object] (Exception(code: 0): at /home/ameer/public_html/livewire.local/vendor/livewire/livewire/src/ComponentConcerns/HandlesActions.php:114)
[stacktrace]
#0 /home/ameer/public_html/livewire.local/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(755): Livewire\\Component->Livewire\\ComponentConcerns\\{closure}()
#1 /home/ameer/public_html/livewire.local/vendor/livewire/livewire/src/ComponentConcerns/HandlesActions.php(121): rescue(Object(Closure), Object(Closure), false)
#2 [internal function]: Livewire\\Component->Livewire\\ComponentConcerns\\{closure}(Object(ReflectionParameter), 0)
#3 /home/ameer/public_html/livewire.local/vendor/laravel/framework/src/Illuminate/Support/Collection.php(1034): array_map(Object(Closure), Array, Array)
#4 /home/ameer/public_html/livewire.local/vendor/livewire/livewire/src/ComponentConcerns/HandlesActions.php(122): Illuminate\\Support\\Collection->map(Object(Closure))
#5 /home/ameer/public_html/livewire.local/vendor/livewire/livewire/src/ComponentConcerns/HandlesActions.php(99): Livewire\\Component->resolveActionParameters('startUpload', Array)
#6 /home/ameer/public_html/livewire.local/vendor/livewire/livewire/src/Connection/ConnectionHandler.php(46): Livewire\\Component->callMethod('startUpload', Array)
...
After some debugging I found that the exception is caused by line #111 in vendor/livewire/livewire/src/ComponentConcerns/HandlesActions.php
I was able to work around the issue by overriding the resolveActionParameters method from the livewire component file.
Changed the method to simply return a collection of $params
protected function resolveActionParameters($method, $params)
{
return collect($params);
}
So far this has prevented the excesive logging of exceptions and didn't break any livewire functionality.

Header Error while using laravel Mail function

While using laravel Mail function , I am recieving the following error:
Header may not contain more than a single header, new line detected
Here is my stacktrace obtained from error logs:
[2015-03-04 23:52:31] production.ERROR: exception 'ErrorException'
with message 'Header may not contain more than a single header, new line detected' in /var/www/pickup/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php:342
Stack trace:
#0 [internal function]: Illuminate\Exception\Handler->handleError(2, 'Header may not ...', '/var/www/pickup...', 342, Array)
#1 /var/www/pickup/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php(342): header('statusText: Exp...', false, 412)
#2 /var/www/pickup/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php(375): Symfony\Component\HttpFoundation\Response->sendHeaders()
#3 /var/www/pickup/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(643): Symfony\Component\HttpFoundation\Response->send()
#4 /var/www/pickup/public/index.php(49): Illuminate\Foundation\Application->run()
#5 {main} [] []
My Mail function is :
public function sendmail($user){
Mail::queue('emails.verify', array('encryption'=>self::encrypt($user->email) , 'name'=>$user->first_name), function($message) use($user)
{
$message->to($user->email, $user->first_name)->subject('[Pickup] Please verify your email '.$user->email);
});
}
It sounds like one of the variables you're sending into the to method contains a newline character, and that the to method expects you sanitize those values yourself.
I'd start with a simple trim call
$message->to(trim($user->email), trim($user->first_name))->subject(
'[Pickup] Please verify your email '.trim($user->email));
If that doesn't work it means one of those variables has a newline in the middle. I'd try logging the values, and then sanitizing the variables based on what you found. Also, if you just want to skip bad data, wrapping everything in a try/catch is another approach
try
{
$message->to(trim($user->email), trim($user->first_name))->subject(
'[Pickup] Please verify your email '.trim($user->email));
}
catch (\Exception $e)
{
\Log::error($e->getMessage());
}

Magento - observer error - "Customer email is required"

I have the following Magento observer which is active when the 'checkout_controller_onepage_save_shipping_method' is executed e.g When a user checkouts and clicks submit on the 'Shipping Method'
My observer functions looks the following:
public function afterShippingMethod($observer)
{
$org_id = Mage::getSingleton('customer/session')->getCustomerOrganisationId(); // always a number eg. 12345
Mage::getSingleton('customer/session')->getCustomer()->setOrganisationId($org_id)->save();
}
This functions runs at the correct time but gives me an Magento error:
There has been an error processing your request
Customer email is required
Clearly the email address is required from the error, but as the email address has already been entered by the customer at the 'Billing Information' stage I cannot understand why I would get this?
Here is stack trace :
Trace:
#0 /vagrant/site.com/public_html/app/code/core/Mage/Customer/Model/Resource/Customer.php(76): Mage::exception('Mage_Customer', 'Customer email ...')
#1 /vagrant/site.com/public_html/app/code/core/Mage/Eav/Model/Entity/Abstract.php(1122): Mage_Customer_Model_Resource_Customer->_beforeSave(Object(Mage_Customer_Model_Customer))
#2 /vagrant/site.com/public_html/app/code/core/Mage/Core/Model/Abstract.php(318): Mage_Eav_Model_Entity_Abstract->save(Object(Mage_Customer_Model_Customer))
#3 /vagrant/site.com/public_html/app/code/local/site/Raptor/Model/Raptor/Observer.php(25): Mage_Core_Model_Abstract->save()
#4 /vagrant/site.com/public_html/app/code/core/Mage/Core/Model/App.php(1338): site_Raptor_Model_Raptor_Observer->afterShippingMethod(Object(Varien_Event_Observer))
#5 /vagrant/site.com/public_html/app/code/core/Mage/Core/Model/App.php(1317): Mage_Core_Model_App->_callObserverMethod(Object(site_Raptor_Model_Raptor_Observer), 'afterShippingMe...', Object(Varien_Event_Observer))
#6 /vagrant/site.com/public_html/app/Mage.php(447): Mage_Core_Model_App->dispatchEvent('checkout_contro...', Array)
#7 /vagrant/site.com/public_html/app/code/core/Mage/Checkout/controllers/OnepageController.php(389): Mage::dispatchEvent('checkout_contro...', Array)
#8 /vagrant/site.com/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(419): Mage_Checkout_OnepageController->saveShippingMethodAction()
#9 /vagrant/site.com/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('saveShippingMet...')
#10 /vagrant/site.com/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#11 /vagrant/site.com/public_html/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#12 /vagrant/site.com/public_html/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#13 /vagrant/site.com/public_html/en-us/index.php(87): Mage::run('en_us', 'store')
The actual error from the stack trace is the following in Customer\Model\Resource\Customer.php
if (!$customer->getEmail()) {
throw Mage::exception('Mage_Customer', Mage::helper('customer')->__('Customer email is required'));
}
Everything is pretty self explanatory with the error, but I cannot work out how to be able to save the organisation_id to this customer object - any ideas?
Any ideas why this would happen & how to fix the error?
I think this applies only for new customers or guests. Have a look at how you retrieve the customer in Mage_Customer_Model_Session::getCustomer(). If the customer has no id, you get an empty customer objcet wihtout data. The data from the billing information step wasn't saved to database yet, so there is no email address at this point.
As a new customer is generated in the last checkout step, when the order is created, customer information has to be stored between the requests. This is done in the quote tables. So you have to add another quote attribute for organisation_id so it can be stored till the customer is generated. For the conversion of the organisation_id from quote to customer some additinal XML configuration in your module config.xml is needed:
<global>
<fieldsets>
<checkout_onepage_quote>
<organisation_id>
<to_customer>organisation_id</to_customer>
</organisation_id>
</checkout_onepage_quote>
</fieldsets>
</global>
For further reference see Mage_Checkout_Model_Type_Onepage::saveOrder():
/**
* Create order based on checkout type. Create customer if necessary.
*
* #return Mage_Checkout_Model_Type_Onepage
*/
public function saveOrder()
{
$this->validate();
$isNewCustomer = false;
switch ($this->getCheckoutMethod()) {
case self::METHOD_GUEST:
$this->_prepareGuestQuote();
break;
case self::METHOD_REGISTER:
$this->_prepareNewCustomerQuote();
$isNewCustomer = true;
break;
default:
$this->_prepareCustomerQuote();
break;
}
For new customers the field conversion takes place in
Mage_Checkout_Model_Type_Onepage::_prepareNewCustomerQuote() with this line:
Mage::helper('core')->copyFieldset('checkout_onepage_quote', 'to_customer', $quote, $customer);
Try this:
public function afterShippingMethod($observer){
$customer=Mage::getSingleton('customer/session');
$orgId=$customer->getCustomerOrganisationId();
$customer->getCustomer()->
setOrganisationId($orgId)->save();
}
An event is fired in the checkout: 'sales_convert_quote_to_order'
this event can be configured in the config.xml of any module like this:
<events>
<sales_convert_quote_to_order>
<observers>
<MODULE_sales_convert_quote_to_order>
<type>singleton</type>
<class>MODULE_Model_Observer</class>
<method>saveCohorts</method>
</MODULE_sales_convert_quote_to_order>
</observers>
</sales_convert_quote_to_order>
</events>
check the modules and maybe you can found the issue

How to fix Magento 1.7 Developer mode

Whenever I am turning on the Developer mode in Magento 1.7 I am getting this warning message
If there is any other warning or error this there it will show that error
But when there is no error this screen is coming.
Once I turn off the developer mode i can use web site.
Warning: get_class() expects parameter 1 to be object, boolean given in >C:\xampp\htdocs\magento\app\code\core\Mage\Core\Model\App.php on line 1340
0 [internal function]: mageCoreErrorHandler(2, 'get_class() exp...', 'C:\xampp\htdocs...', >1340, Array) #1 C:\xampp\htdocs\magento\app\code\core\Mage\Core\Model\App.php(1340): >get_class(false) #2 C:\xampp\htdocs\magento\app\code\core\Mage\Core\Model\App.php(1317): >Mage_Core_Model_App->_callObserverMethod(false, 'check', Object(Varien_Event_Observer)) #3 >C:\xampp\htdocs\magento\app\Mage.php(447): Mage_Core_Model_App->dispatchEvent('controller_fron...', Array) #4 >C:\xampp\htdocs\magento\app\code\core\Mage\Core\Controller\Varien\Front.php(147): ?>Mage::dispatchEvent('controller_fron...', Array) #5 >C:\xampp\htdocs\magento\app\code\core\Mage\Core\Model\App.php(749): ?>Mage_Core_Controller_Varien_Front->init() #6 >C:\xampp\htdocs\magento\app\code\core\Mage\Core\Model\App.php(1094): Mage_Core_Model_App->_initFrontController() #7 >C:\xampp\htdocs\magento\app\code\core\Mage\Core\Model\App.php(354): Mage_Core_Model_App->getFrontController() #8 C:\xampp\htdocs\magento\app\Mage.php(683): Mage_Core_Model_App->run(Array) #9 C:\xampp\htdocs\magento\index.php(87): Mage::run('', 'store') #10 {main}
Any help or guidance would we appreciated.
You have a defunct observer; see Mage_Core_Model_App::_callObserverMethod() (link):
protected function _callObserverMethod($object, $method, $observer)
{
if (method_exists($object, $method)) {
$object->$method($observer);
} elseif (Mage::getIsDeveloperMode()) {
Mage::throwException('Method "'.$method.'" is not defined in "'.get_class($object).'"');
}
return $this;
}
From the rest of the stack trace it's possible to see that the event being observed is controller_front_init_routers (ref. Mage_Core_Controller_Varien_Front::init() (link)). Unless something has gone awry with Mage_Cms_Controller_Router (link), the issue must be with a custom module which is configured to observe this event.
To find the offending configuration, search in app/code for <controller_front_init_routers>.
You could also create a test script which does not invoke the Front Controller and use it to debug:
<?php
ini_set('display_errors',true);
error_reporting(E_ALL | E_STRICT);
include 'app/Mage.php';
Mage::setIsDeveloperMode(true);
Mage::app();
Zend_Debug::dump(
Mage::getConfig()->getXpath('//controller_front_init_routers//class')
);
Stock output would be as follows; anything else is your troublemaker:
array(1) {
[0] => object(Mage_Core_Model_Config_Element)#66 (1) {
[0] => string(26) "Mage_Cms_Controller_Router"
}
}

Magento model ends up with Invalid method xxx::beginTransaction(Array()

I am trying to write data to a table in the database. I finally set up my model but I can not write data to it.
I keep getting this error:
Invalid method Turnkeye_Adminform_Model_Mysql4_Iaso::beginTransaction(Array
(
)
)
Trace:
#0 E:\projects\magento\app\code\core\Mage\Core\Model\Abstract.php(313): Varien_Object->__call('beginTransactio...', Array)
#1 E:\projects\magento\app\code\core\Mage\Core\Model\Abstract.php(313): Turnkeye_Adminform_Model_Mysql4_Iaso->beginTransaction()
#2 E:\projects\magento\app\code\community\Turnkeye\Adminform\controllers\Adminhtml\AdminformController.php(47): Mage_Core_Model_Abstract->save()
#3 E:\projects\magento\app\code\core\Mage\Core\Controller\Varien\Action.php(420): Turnkeye_Adminform_Adminhtml_AdminformController->saveAction()
#4 E:\projects\magento\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('save')
#5 E:\projects\magento\app\code\core\Mage\Core\Controller\Varien\Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#6 E:\projects\magento\app\code\core\Mage\Core\Model\App.php(347): Mage_Core_Controller_Varien_Front->dispatch()
#7 E:\projects\magento\app\Mage.php(640): Mage_Core_Model_App->run(Array)
#8 E:\projects\magento\index.php(80): Mage::run('', 'store')
#9 {main}
Because of the amount of code I have posted it to pastebin:
controllers/Adminhtml/AdminformController.php
etc/config.xml
etc/adminhtml.xml
Model/iaso.php
Model/Mysql4/Iaso.php
This does not work because your code defines
Turnkeye_Adminform_Model_Mysql4_Iaso extends Mage_Core_Model_Abstract
which is wrong.
You need to extend from a resource model, that is from a class, which is extending the abstract class Mage_Core_Model_Resource_Abstract. That's where beginTransaction() is defined.
Usually this is done by extending from Mage_Core_Model_Mysql4_Abstract, because there are some more methods standard mySQL resources use in Magento and these are defined thru:
Mage_Core_Model_Mysql4_Abstract extends
Mage_Core_Model_Resource_Db_Abstract extends
Mage_Core_Model_Resource_Abstract
So changing your definition to
Turnkeye_Adminform_Model_Mysql4_Iaso extends Mage_Core_Model_Mysql4_Abstract
should bring you back on the right track.

Resources