CodeIgniter Hooks Pre Controller - php

I want to use different databases for different language files. I can get language code with this;
$this->lang->lang()
I have to define it as pre_controller hook, so system will select right database at the beginning. But when I try to use the code above, I'm getting a fatal error.
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_Hooks::$lang
Filename: config/hooks.php
Line Number: 13
Fatal error: Call to a member function lang() on a non-object in...
This is my code;
$hook['pre_controller'] = define('LANG', isset($_SESSION['lang']) ? $_SESSION['lang'] : $this->lang->lang());
Thanks in advance.

Related

Fatal error: Cannot redeclare imagecreatefrombmp()

I'm working on a simple imageboard based by TinyBoard (xampp), when I try to post with image, website gives me error for some reason:
Fatal error: Cannot redeclare imagecreatefrombmp() in C:\xampp\htdocs\inc\image.php on line 584
image.php:
[1]https://pastebin.com/xqj2NAuX
(584 line = 77 line)
PHP 7.2, any help?
ANSWER:
Just change the function name to something else on line 1:
function imagecreatefrombmp2($filename)
(from user3647971)
Just change the function name to something else on line 1 :
function imagecreatefrombmp2($filename) {
the error warns you that a function named exactly like this has already been declared. It's a built-in php function: http://php.net/manual/en/function.imagecreatefrombmp.php

Undefined variable and trying to get propery of non-object error prestashop

Notice: Trying to get property of non-object in /var/www/html/cy_prestashop/modules/taxcloud/taxcloud.php on lineĀ 699
Notice: Undefined variable: smarty in /var/www/html/cy_prestashop/modules/taxcloud/taxcloud.php on lineĀ 699
Im using prestashop version 1.5.6.2 . How to resolve above this error.
This is my code error occured page,
Taxcloud/taxcloud.php: line no 699,
$page_name = $psv >= 1.4 && Configuration::get('PS_FORCE_SMARTY_2') == 0 ?
$smarty->tpl_vars['page_name']->value :
$smarty->get_template_vars('page_name');
In PrestaShop 1.5.x the global $smarty var is deprecated.
You have to use:
$this->context->smarty
If also that snippet give you problem use this:
Context::getContext()->smarty

What is the equivalent of isset for object's methods in CodeIgniter?

In my CodeIgniter application I use session class in some controllers (Not all of them) and I have fixed theme view rendered in all page. I'd like to use session->setflash() in the view. So, for controllers that don't use session I have to check if the session->flashdata() is set or available or not. I have tried the follwoing:
<?php if (isset($this->session->flashdata('msg'))):;?>
It returned the following error:
Fatal error: Cannot use isset() on the result of a function call (you
can use "null !== func()" instead)
When I tried the suggestion of the message:
<?php if (null !== $this->session->flashdata('msg')):;?>
I got the following error:
Fatal error: Call to a member function flashdata() on a non-object
in...
Beside a codeIgniter error:
A PHP Error was encountered Severity: Notice
Message: Undefined property: CI_Loader::$session
Filename: themes/head.php
Line Number: 44
If your controller is always loading $this->load->library('session');
Then you'd be able to just check if($this->session->flashdata('msg')){/*do stuff*/}
Otherwise you could use method_exists()
http://php.net/manual/en/function.method-exists.php
if(method_exists('CI_Session', 'flashdata') && $this->session->flashdata('msg')){
echo $this->session->flashdata('msg');
}

Fatal error: Call to a member function in product.php

I am new to opencart, so please help me.
I am using opencart version 1.5.6, now whenever I edit and delete the product it shows me
Fatal error: Call to a member function productUpdateListen() on a non-object in /home/crazepur/public_html/admin/controller/catalog/product.php on line 78
and
Fatal error: Call to a member function deleteProduct() on a non-object in /home/crazepur/public_html/admin/controller/catalog/product.php on line 133 respectively.
Although it edit and delete the product.
Please help me how to fix it.
Code in Line 78 $this->openbay->productUpdateListen($this->request->get['product_id'], $this->request->post);
And code in line 133 $this->openbay->deleteProduct($product_id);
This means $this->openbay is not an object which contains function productUpdateListen() & deleteProduct(), probably it's NULL or false in some cases (nothing found) due to it's not accessible. Out of scope.
Try
var_dump($this->openbay);
Check the O/P
it's simple and the error-message says it all: your $this->openbay doesn't have those methods (productUpdateListen() and deleteProduct()) - most likely it isn't an object at all.
please debug your code since it's impossible to say what's going wrong wich so little information. to start, do a var_dump($this->openbay); right before the function-calls and check the output.

PHP Fatal error: Cannot redeclare frm_dl() wordpress

i'm having a 500 internal server problem. http://www.bunchmag.com/
500 internal server error Fatal error: Cannot redeclare frm_dl
20130329T141539: www.bunchmag.com/index.php PHP Fatal error: Cannot
redeclare frm_dl() (previously declared in
/hermes/web09/aksjhfks/moo.bunchmagazinecom/bunch/index.php(1) :
eval()'d code:1) in
/hermes/web09/skjfljf/moo.bunchmagazinecom/bunch/wp-config.php(1) :
eval()'d code on line 10
my hosting tech support is working on it but any help would be greatly appreciated!
Locate where the function is being declared and wrap it in an if statement to ensure the function is not already declared.
if( !function_exists( "frm_dl" ) ){
function frm_dl(..){
...
}
}
this should solve the issue if its the same file being included twice.
alternatively, search for multiple files declaring the function and wrap each one in the conditional statement, or change on of the function names (if possible)

Categories