I don't find exactly where is my problem. It seems the objectinfo is empty and
I have this error on.
Fatal error: Call to undefined method objectInfo::objectInfo() on this line $bInfo->objectInfo($banner);
My sql request work fine and I verified
There my code where is the problem.
Tk
$parameters = array('expires_date' => '',
'date_scheduled' => '',
'banners_title' => '',
'banners_url' => '',
'banners_group' => '',
'banners_target' => '',
'banners_image' => '',
'banners_html_text' => '',
'expires_impressions' => '',
'banners_title_admin' => ''
);
$bInfo = new objectInfo($parameters);
$bID = HTML::sanitize($_GET['bID']);
$Qbanner = $OSCOM_PDO->prepare('select banners_title,
banners_url,
banners_image,
banners_group,
banners_target,
banners_html_text,
status,
date_format(date_scheduled, "%Y-%m-%d") as date_scheduled,
date_format(expires_date, "%d/%m/%Y") as expires_date,
expires_impressions,
date_status_change ,
customers_group_id,
languages_id,
banners_title_admin
from :table_banners
where banners_id = :banners_id
');
$Qbanner->bindInt(':banners_id', (int)$bID);
$Qbanner->execute();
$banner = $Qbanner->fetch();
$bInfo->objectInfo($banner); // pb is here
As par i know this Fatal error occur due to the updated version of the php.
Earlier, we are able to autoload the class property by using the same function name of the class name.
In Earlier varsion of PHP, we can able to call or define the Same Function name of the class name.
But new the Latest version of php we can not do that. if we use the same function name of the class name and if we call this function name then it give us the fatal error like you received in this post.
So the solution is as follow.
Go to the class objectInfo ( or whatever you have )
your class file is currently have
class objectInfo {
function objectInfo($object_array) {
your function code here.....
}
}
Change the function name from objectInfo to __construct. so the entire class is looking like as below
class objectInfo {
function __construct($object_array) {
your function code here.....
}
}
currently you call the function like
$bInfo = new objectInfo($parameters);
$bInfo->objectInfo($banner);
so change above code as below.
$bInfo = new objectInfo($parameters);
$bInfo->__construct($banner);
so finally hope that your error will be solved.
The line $bInfo = new objectInfo($parameters); created a new instance of the objectInfo class. Then you attempt to call the method objectInfo() of this class. The error message just tells you that this class has no such method. Can you show the source code for the class objectInfo?
Related
Im trying to send a email with a list of companies that have the pending or waiting status.
This list is already collected in the following function:
public static function getCompaniesAwaitingCheck()
{
$awaitingChangeApproval = self::getAwaitingChangeApproval();
$awaitingPublication = self::getAwatingPublication();
return array_merge($awaitingChangeApproval, $awaitingPublication);
}
Now I want to use that function to put in the email. I have made a separate class for this (AdminPendingApprovalNotification.php)
In there is the following function:
public function notifyPendingApproval()
{
$dailyClaimMailTitle = get_field("daily_claim_overview_mail_title", 'options');
$dailyClaimMailText = get_field('daily_claim_overview_mail_text', 'options');
$dailyClaimMailAddress = get_field('daily_claim_overview_mail', 'options');
$company = new Company();
$pendingCompany = $company->getCompaniesAwaitingCheck();
wp_mail(
$dailyClaimMailAddress,
ecs_get_template_part('views/email/template', [
'title' => $dailyClaimMailTitle,
'text' => $dailyClaimMailText, $pendingCompany,
], false),
['Content-Type: text/html; charset=UTF-8']
);
}
When I dd($pendingCompany); I get the error:PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function Models\Model::__construct(), 0 passed in Emails/AdminPendingApprovalNotification.php on line 16 and exactly 1 expected
line 16: $company = new Company();
Unfortunately can’t get it to work, I’m a beginner, some help would be appreciated. Thanks!
Your method getCompaniesAwaitingCheck is static, so you should call it like:
$pendingCompany = Company::getCompaniesAwaitingCheck();
An error occured because your Company class requires arguments in the __construct method, which you didn't provide.
My error: I am facing this issue quite long time and found one solution in stackoverflow but it doesn't work. I need solution to work with laravel , php 7+ and mysql.
It is showing below error:
ErrorException
Trying to get property 'app_layout' of non-object
Error page consists following code and i tried all solutions in stack overflow but no us. I want to show my layout without any error here.
Error in the script\app\Http\Controllers\MainBaseController.php:26
code on the page is : error line highlighted in BOLD below
use Illuminate\Support\Facades\Schema;
use Froiden\Envato\Traits\AppBoot;
class MainBaseController extends Controller
{
public function __construct()
{
parent::__construct();
// Settings
$this->settings = Setting::first();
$this->year = Common::year();
$this->bootstrapModalRight = true;
$this->bootstrapModalSize = 'md';
**$this->siteLayout = $this->settings->app_layout; // top, sidebar**
$this->forbiddenErrorView = 'errors.403';
$this->showFooter = true;
$this->rtl = $this->settings->rtl;
// Status
$this->statusArray = [
'enabled' => __('app.enabled'),
'disabled' => __('app.disabled')
];
// Setting assets path
$allPaths = Common::getFolderPath();
foreach($allPaths as $allPathKey => $allPath)
{
$this->{$allPathKey} = $allPath;
I am placing error part of the code above , if you need any other parts i will provide
I'm writing a CodeIgniter library around PHP's bbcode PECL extension, but I'm having some trouble with callbacks.
I set up the handler in the library constructor:
function __construct() {
$basic = array(
'url' => array(
'type' => BBCODE_TYPE_OPTARG,
'open_tag' => '<a href="{PARAM}" rel="nofollow">',
'close_tag' => '</a>',
'childs'=>'i,b,u,strike,center,img',
'param_handling' => array($this, 'url')
)
);
$this->handler = bbcode_create($basic);
}
public function parse($bbcode_string) {
return bbcode_parse($this->handler, htmlentities($bbcode_string));
}
As you notice, this uses a callback for handling what's allowed to go into the URL. I use this to insert an "exit redirect" page
public static function url($content, $argument) {
if (!$argument) $argument = $content;
$url = parse_url($argument);
if (!isset($url['host'])) {
if (strlen($argument) > 0 && $argument[0] != '/') return false;
$destination = '//'.$_SERVER['HTTP_HOST'].$argument;
} elseif ($url['host'] != $_SERVER['HTTP_HOST']) {
$destination = '//'.$_SERVER['HTTP_HOST'].'/exit?'.urlencode($argument);
} else {
$destination = $argument;
}
return htmlspecialchars($destination);
}
And I also have a little function which helps me test this out as I work:
function test() {
$string = '[url]http://www.google.com[/url]';
echo '<pre>';
die($this->parse($string));
}
This all works fine if the test() method is called from within the library. For example, if I throw $this->test() at the bottom of the constructor, everything works exactly as I would expect. However, calling $this->bbcode->test() from somewhere else (e.g. in a controller), I get the following errors:
**A PHP Error was encountered**
Severity: Warning
Message: Invalid callback , no array or string given
Filename: libraries/bbcode.php
Line Number: 122
**A PHP Error was encountered**
Severity: Warning
Message: bbcode_parse(): function `' is not callable
Filename: libraries/bbcode.php
Line Number: 122
http://www.google.com
The callback does not get executed, and as a result the link's href attribute is empty. Line 122 refers to the single line of code in my parse function:
return bbcode_parse($this->handler, htmlentities($bbcode_string));
How do I address this callback function such that it can be located when $this->bbcode->test() is called from inside a controller?
Now I'm even more confused...
So in the hopes of just putting this all behind me, I put these callback functions in a helper so I can just call them directly. So I now have code like this:
function __construct() {
$basic = array(
'url' => array(
'type' => BBCODE_TYPE_OPTARG,
'open_tag' => '<a href="{PARAM}" rel="nofollow">',
'close_tag' => '</a>',
'childs'=>'i,b,u,strike,center,img',
'param_handling' => 'bbcode_url'
)
);
$this->handler = bbcode_create($basic);
}
With the above, I get the following error:
**A PHP Error was encountered**
Severity: Warning
Message: Invalid callback 6.7949295043945E-5, no array or string given
Filename: libraries/bbcode.php
Line Number: 176
**A PHP Error was encountered**
Severity: Warning
Message: bbcode_parse(): function `6.7949295043945E-5' is not callable
Filename: libraries/bbcode.php
Line Number: 176
(line 176 is the new location of the parse() function)
Um... I don't even know what's going on. The number 6.7949295043945E-5 changes with every attempt.
The only solution I have found to this is quite simply not to set the handler up in a constructor. Instead, the parse() method contains both the bbcode_create() call and the bbcode_parse() call. That is, the bbcode_handler is freshly created for every string of bbcode to be parsed.
This seems needlessly wasteful to me. But, over the course of the lifetime of this project, it is exceedingly unlikely to cost even a tenth of the amount of time that I have spent trying to sort this out "properly", so I'm calling it a day.
I'm posting this "solution" here in case somebody else happens across this question and can thereby save themselves a few hours' pain. That said, I would really like to know what on earth is going on, and how to do this properly.
This question already has answers here:
Reference - What does this error mean in PHP?
(38 answers)
Closed 8 years ago.
I'm facing an error message:
Fatal error: Call to a member function isUploaded() on a non-object in /www/htdocs/nether/http/123factuur/application/controllers/Helpers/ImportXls.php on line 30
To my understanind this error message pops-up because I'm calling a method which doesn't exists in the object. But I'm sure that isUploaded() does exists.
The function isUploaded is defined in the class Zend_Form_Element_File. To check if $xls is an instance of the Zend_Form_Element_File I debugged the $xls variable.
Zend_Debug::dump($xls); //OUTPUT: object(Zend_Form_Element_File)#141 (29) {
exit;
Line 30 looks like this:
if ( $xls->isUploaded() ) {
The first thing I did was to check the expression value.
Zend_Debug::dump($xls->isUploaded()); //the output was: bool(true)
exit;
Then I checked the type of the $xls variable.
echo gettype($xls); //the output was object
exit;
I'm not fully understanding the error. Perhaps, I'm not interpreting the error message as it should be interpreted. Anyway, assistance is needed.
The code snippet:
At the controller:
public function importAction() {
$form = $this->getImportFrom();
$this->view->form = $form;
$this->view->allowedHeaders = array();
$this->importInvoices($form);
$this->importInvoiceArticles($form);
$this->importInvoiceServices($form);
foreach ($this->_lookupIssues as $issue) {
$this->_flashMessenger->addMessage($issue);
}
}
public function importInvoiceArticles($form) {
$model = 'Invoice_article';
$config = Zim_Properties::getConfig($model);
$Model = new Zim_Model($model, $config->model);
$headerMapping = array_flip(array_intersect_key($Model->getHeaders(true), array_flip($this->_allowedArticleImportHeaders)));
$this->getHelper('ImportXls')->handleImport($form, $headerMapping, $Model->getName(), $this->_modelName, null, null, array($this, 'saveImportedArticleData'), 'invoiceArticle');
}
At the helper:
class F2g_Helper_ImportXls extends Zend_Controller_Action_Helper_Abstract {
public function handleImport($form, $allowedHeaders, $tableName, $modelName, $onDuplicateImportCallback, $importMethod = null, $saveMethod = null, $name = 'xls') {
if ($this->getRequest()->isPost()) {
$xls = $form->getElement($name);
if ( $xls->isUploaded() ) {
//some code
}
}
}
}
I'm quite sure that the handleImport() method is called multiple times, possibly inside a loop, probably with different values for the $name parameter. You echo the variable and die in order to debug it, which works perfectly if the provided value for $name is correct on the first run - but since you kill the script - you don't get any debug information about subsequent calls.
Make sure the object has that method before calling it. You can either call method_exists() or instanceof to make that determination.
Code:
if ($xls instanceof Zend_Form_Element_File) {
// object of correct type - continue (preferred version)
}
// or
if (method_exists($xls, 'isUploaded')) {
// avoids the error, but does not guarantee that
// other methods of the Zend_Form_Element_File exist
}
Add this to your condition to avoid the Fatal Error :
if ( !empty($xls) && is_object($xls) && $xls->isUploaded() ) {
// do your job with serenity :)
}
I am having an issue that coming from PHP 5.3.2 to 5.3.3 the code no longer can find the "I2A2" class.
Here is some info:
Error:
ErrorException [ Error ]: Class 'I2A2' not found
Fatal error: Class 'I2A2' not found in /var/www/html/root/sandbox/lpolicin/t6/fuel/app/classes/observer/selectcustomer.php on line 6
$directory_listing = \I2A2::get_customer_info("puid",$customer->puid);
Code:
"classes/observer/selectcustomer.php "
class Observer_Selectcustomer extends Orm\Observer
{
public function after_load(Model_Customer $customer)
{
$directory_listing = \I2A2::get_customer_info("puid",$customer->puid);
}
}
"classes/I2A2.php"
class I2A2
{
if (static::$initalized === true)
{
return;
}
}
Auto loader (this is insert into a huge array then auto loads everyting)....
{
'always_load' => array(
'classes' => array(),
}
If you need more info please let me know!
Check your paths: the first is correctly fully lowercase but the second suddenly has the filename uppercase. All paths in Fuel are fully lowercase, no matter the classname. Thus change the filename for the I2A2 class to i2a2.php and it'll work.